Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Mar 4, 2024
1 parent b9144a4 commit cdb25e6
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 114 deletions.
2 changes: 2 additions & 0 deletions modules/core-tests/test/adapter/resources/buffer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

/* eslint-disable no-continue */

import test from 'tape-promise/tape';
import {getTestDevices, webglDevice} from '@luma.gl/test-utils';

Expand Down
86 changes: 43 additions & 43 deletions modules/core-tests/test/adapter/resources/command-buffer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,42 @@ const EPSILON = 1e-6;
const {abs} = Math;

test('CommandBuffer#copyBufferToBuffer', async t => {
const sourceData = new Float32Array([1, 2, 3]);
const source = device.createBuffer({data: sourceData});
const destinationData = new Float32Array([4, 5, 6]);
const destination = device.createBuffer({data: destinationData});

let receivedData = await readAsyncF32(destination);
let expectedData = new Float32Array([4, 5, 6]);
t.deepEqual(receivedData, expectedData, 'copyBufferToBuffer: default parameters successful');

let commandEncoder = device.createCommandEncoder();
commandEncoder.copyBufferToBuffer({
source,
destination,
size: 2 * Float32Array.BYTES_PER_ELEMENT
});
commandEncoder.finish();
commandEncoder.destroy();

receivedData = await readAsyncF32(destination);
expectedData = new Float32Array([1, 2, 6]);
t.deepEqual(receivedData, expectedData, 'copyBufferToBuffer: with size successful');

commandEncoder = device.createCommandEncoder();
commandEncoder.copyBufferToBuffer({
source,
sourceOffset: Float32Array.BYTES_PER_ELEMENT,
destination,
destinationOffset: 2 * Float32Array.BYTES_PER_ELEMENT,
size: Float32Array.BYTES_PER_ELEMENT
});
commandEncoder.finish();
commandEncoder.destroy();
const sourceData = new Float32Array([1, 2, 3]);
const source = device.createBuffer({data: sourceData});
const destinationData = new Float32Array([4, 5, 6]);
const destination = device.createBuffer({data: destinationData});

let receivedData = await readAsyncF32(destination);
let expectedData = new Float32Array([4, 5, 6]);
t.deepEqual(receivedData, expectedData, 'copyBufferToBuffer: default parameters successful');

let commandEncoder = device.createCommandEncoder();
commandEncoder.copyBufferToBuffer({
source,
destination,
size: 2 * Float32Array.BYTES_PER_ELEMENT
});
commandEncoder.finish();
commandEncoder.destroy();

receivedData = await readAsyncF32(destination);
expectedData = new Float32Array([1, 2, 6]);
t.deepEqual(receivedData, expectedData, 'copyBufferToBuffer: with size successful');

receivedData = await readAsyncF32(destination);
expectedData = new Float32Array([1, 2, 2]);
t.deepEqual(receivedData, expectedData, 'copyBufferToBuffer: with size and offsets successful');
commandEncoder = device.createCommandEncoder();
commandEncoder.copyBufferToBuffer({
source,
sourceOffset: Float32Array.BYTES_PER_ELEMENT,
destination,
destinationOffset: 2 * Float32Array.BYTES_PER_ELEMENT,
size: Float32Array.BYTES_PER_ELEMENT
});
commandEncoder.finish();
commandEncoder.destroy();

receivedData = await readAsyncF32(destination);
expectedData = new Float32Array([1, 2, 2]);
t.deepEqual(receivedData, expectedData, 'copyBufferToBuffer: with size and offsets successful');

t.end();
});
Expand Down Expand Up @@ -113,14 +113,14 @@ const COPY_TEXTURE_TO_BUFFER_FIXTURES: CopyTextureToBufferFixture[] = [
];

test('CommandBuffer#copyTextureToBuffer', async t => {
for (const fixture of COPY_TEXTURE_TO_BUFFER_FIXTURES) {
await testCopyTextureToBuffer(t, device, {...fixture});
await testCopyTextureToBuffer(t, device, {
...fixture,
useFramebuffer: true,
title: `${fixture.title} + framebuffer`
});
}
for (const fixture of COPY_TEXTURE_TO_BUFFER_FIXTURES) {
await testCopyTextureToBuffer(t, device, {...fixture});
await testCopyTextureToBuffer(t, device, {
...fixture,
useFramebuffer: true,
title: `${fixture.title} + framebuffer`
});
}

t.end();
});
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/adapter/resources/framebuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export abstract class Framebuffer extends Resource<FramebufferProps> {
if (this.props.colorAttachments.length === 0 && !this.props.depthStencilAttachment) {
throw new Error('Framebuffer has noattachments');
}

this.colorAttachments = this.props.colorAttachments.map(attachment => {
if (typeof attachment === 'string') {
const texture = this.createColorTexture(attachment);
Expand Down
56 changes: 28 additions & 28 deletions modules/engine/test/scenegraph/group-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,33 @@ test('GroupNode#traverse', t => {
});

test('GroupNode#getBounds', t => {
const matrix = new Matrix4().translate([0, 0, 1]).scale(2);

const model1 = new Model(device, {id: 'childSNode', vs: DUMMY_VS, fs: DUMMY_FS});
const model2 = new Model(device, {id: 'grandChildSNode', vs: DUMMY_VS, fs: DUMMY_FS});
const childSNode = new ModelNode({model: model1});
const grandChildSNode = new ModelNode({model: model2});
const child1 = new GroupNode({id: 'child-1', matrix, children: [grandChildSNode]});
const groupNode = new GroupNode({id: 'parent', matrix, children: [child1, childSNode]});

t.deepEqual(groupNode.getBounds(), null, 'child bounds are not defined');

childSNode.bounds = [
[0, 0, 0],
[1, 1, 1]
];
grandChildSNode.bounds = [
[-1, -1, -1],
[0, 0, 0]
];

t.deepEqual(
groupNode.getBounds(),
[
[-4, -4, -1],
[2, 2, 3]
],
'bounds calculated'
);
const matrix = new Matrix4().translate([0, 0, 1]).scale(2);

const model1 = new Model(device, {id: 'childSNode', vs: DUMMY_VS, fs: DUMMY_FS});
const model2 = new Model(device, {id: 'grandChildSNode', vs: DUMMY_VS, fs: DUMMY_FS});
const childSNode = new ModelNode({model: model1});
const grandChildSNode = new ModelNode({model: model2});
const child1 = new GroupNode({id: 'child-1', matrix, children: [grandChildSNode]});
const groupNode = new GroupNode({id: 'parent', matrix, children: [child1, childSNode]});

t.deepEqual(groupNode.getBounds(), null, 'child bounds are not defined');

childSNode.bounds = [
[0, 0, 0],
[1, 1, 1]
];
grandChildSNode.bounds = [
[-1, -1, -1],
[0, 0, 0]
];

t.deepEqual(
groupNode.getBounds(),
[
[-4, -4, -1],
[2, 2, 3]
],
'bounds calculated'
);
t.end();
});
20 changes: 10 additions & 10 deletions modules/engine/test/transform/buffer-transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ void main() { fragColor.x = dst; }
`;

test('BufferTransform#constructor', async t => {
t.ok(createBufferTransform(webglDevice), 'WebGL succeeds');
t.ok(createBufferTransform(webglDevice), 'WebGL succeeds');
t.end();
});

test('BufferTransform#run', async t => {
const SRC_ARRAY = new Float32Array([0, 1, 2, 3, 4, 5]);
const DST_ARRAY = new Float32Array([0, 1, 4, 9, 16, 25]);

const src = webglDevice.createBuffer({data: SRC_ARRAY});
const dst = webglDevice.createBuffer({byteLength: 24});
const elementCount = 6;
const transform = createBufferTransform(webglDevice, src, dst, elementCount);
const src = webglDevice.createBuffer({data: SRC_ARRAY});
const dst = webglDevice.createBuffer({byteLength: 24});
const elementCount = 6;
const transform = createBufferTransform(webglDevice, src, dst, elementCount);

transform.run();
transform.run();

const bytes = await transform.readAsync('dst');
const array = new Float32Array(bytes.buffer, bytes.byteOffset, elementCount);
t.deepEqual(array, DST_ARRAY, 'output transformed');
const bytes = await transform.readAsync('dst');
const array = new Float32Array(bytes.buffer, bytes.byteOffset, elementCount);
t.deepEqual(array, DST_ARRAY, 'output transformed');

t.end();
t.end();
});

function createBufferTransform(
Expand Down
64 changes: 32 additions & 32 deletions modules/webgl/test/adapter/resources/webgl-buffer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {WEBGLBuffer} from '@luma.gl/webgl';
import {webglDevice as device} from '@luma.gl/test-utils';

test('WEBGLBuffer#bind/unbind with index', t => {
const buffer = device.createBuffer({usage: Buffer.UNIFORM});
device.gl.bindBufferBase(buffer.glTarget, 0, buffer.handle);
t.ok(buffer instanceof Buffer, `${device.info.type} Buffer bind/unbind with index successful`);
device.gl.bindBufferBase(buffer.glTarget, 0, null);
const buffer = device.createBuffer({usage: Buffer.UNIFORM});
device.gl.bindBufferBase(buffer.glTarget, 0, buffer.handle);
t.ok(buffer instanceof Buffer, `${device.info.type} Buffer bind/unbind with index successful`);
device.gl.bindBufferBase(buffer.glTarget, 0, null);

buffer.destroy();
buffer.destroy();

t.end();
});
Expand All @@ -23,42 +23,42 @@ test('WEBGLBuffer#write', async t => {
const initialData = new Float32Array([1, 2, 3]);
const updateData = new Float32Array([4, 5, 6]);

let buffer: WEBGLBuffer;
let buffer: WEBGLBuffer;

buffer = device.createBuffer({usage: Buffer.VERTEX, data: initialData});
buffer = device.createBuffer({usage: Buffer.VERTEX, data: initialData});

t.deepEqual(
await readAsyncF32(buffer),
initialData,
`${device.info.type} Device.createBuffer(ARRAY_BUFFER) successful`
);
t.deepEqual(
await readAsyncF32(buffer),
initialData,
`${device.info.type} Device.createBuffer(ARRAY_BUFFER) successful`
);

buffer.write(updateData);
buffer.write(updateData);

t.deepEquals(
await readAsyncF32(buffer),
updateData,
`${device.info.type} Buffer.write(ARRAY_BUFFER) successful`
);
t.deepEquals(
await readAsyncF32(buffer),
updateData,
`${device.info.type} Buffer.write(ARRAY_BUFFER) successful`
);

buffer.destroy();
buffer = device.createBuffer({usage: Buffer.INDEX, data: initialData});
buffer.destroy();
buffer = device.createBuffer({usage: Buffer.INDEX, data: initialData});

t.deepEqual(
await readAsyncF32(buffer),
initialData,
`${device.info.type} Device.createBuffer(ELEMENT_ARRAY_BUFFER) successful`
);
t.deepEqual(
await readAsyncF32(buffer),
initialData,
`${device.info.type} Device.createBuffer(ELEMENT_ARRAY_BUFFER) successful`
);

buffer.write(updateData);
buffer.write(updateData);

t.deepEqual(
await readAsyncF32(buffer),
updateData,
`${device.info.type} Buffer.write(ARRAY_ELEMENT_BUFFER) successful`
);
t.deepEqual(
await readAsyncF32(buffer),
updateData,
`${device.info.type} Buffer.write(ARRAY_ELEMENT_BUFFER) successful`
);

buffer.destroy();
buffer.destroy();

t.end();
});
Expand Down

0 comments on commit cdb25e6

Please sign in to comment.