Skip to content

Commit

Permalink
Merge 7f096db into 35e5662
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Mar 4, 2024
2 parents 35e5662 + 7f096db commit 3aae9a9
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 118 deletions.
13 changes: 7 additions & 6 deletions docs/api-reference/core/resources/framebuffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,15 @@ Resizes all the `Framebuffer`'s current attachments to the new `width` and `heig
- `width` - the new width of `Framebuffer` in pixels
- `height` - the new height of `Framebuffer` in pixels

Returns itself to enable chaining

Note the `framebuffer.resize()` method has been designed so that it can be called every frame without performance concerns. While the actual resizing of attachments can be expensive, the `resize()` methods checks if `width` or `height` have changed before actually resizing any attachments.

## Remarks

- WebGPU: `resize()` will destroy and recreate textures (meaning the the underlying `GPUTexture` / `GPUTextureView` handles are no longer the same after a `resize()`
- WebGL: `resize()` will erase the current content of any attachments, but not actually create them (The underlying`WebGLTexture` / `WebGLRenderbuffer` handles are not changed).
- WebGPU: The `Framebuffer` class is a pure luma.gl class as this concept does not exist natively in WebGPU (attachment information has to be provided through the `GPURenderPassDescriptor` `colorAttachments` and the `depthStencilAttachment` fields every frame when a render pass is created).`.
- WebGL: The `Framebuffer` class wraps the `WebGLFramebuffer` object exists, see e.g. [Framebuffer](https://www.khronos.org/opengl/wiki/Framebuffer)
WebGPU
- The `Framebuffer` class is a pure luma.gl class as this concept does not exist natively in WebGPU (attachment information has to be provided through the `GPURenderPassDescriptor` `colorAttachments` and the `depthStencilAttachment` fields every frame when a render pass is created).`.
- `resize()` will destroy and recreate textures (meaning the the underlying `GPUTexture` / `GPUTextureView` handles are no longer the same after a `resize()`

WebGL
- The `Framebuffer` class wraps the `WebGLFramebuffer` object exists, see e.g. [Framebuffer](https://www.khronos.org/opengl/wiki/Framebuffer)
and [Framebuffer Object](https://www.khronos.org/opengl/wiki/Framebuffer_Object) in the OpenGL Wiki.
- `resize()` will erase the current content of any attachments, but not actually recreate them (The underlying`WebGLTexture` handles are not changed).
72 changes: 47 additions & 25 deletions modules/core-tests/test/adapter/resources/texture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,9 @@ import {SAMPLER_PARAMETERS} from './sampler.spec';
import {WEBGLTexture} from '@luma.gl/webgl/adapter/resources/webgl-texture';
// import {convertToSamplerProps} from '@luma.gl/webgl/adapter/converters/sampler-parameters';

test('WebGL#Texture construct/delete', async t => {
for (const device of await getTestDevices()) {
const texture = device.createTexture({});
t.ok(texture instanceof Texture, 'Texture construction successful');
texture.destroy();
t.ok(texture instanceof Texture, 'Texture delete successful');
texture.destroy();
t.ok(texture instanceof Texture, 'Texture repeated delete successful');
}
t.end();
});

test('WebGLDevice#isTextureFormatSupported()', async t => {
test('Device#isTextureFormatSupported()', async t => {
const FORMATS: Record<string, TextureFormat[]> = {
webgl: ['rgba8unorm'],
webgl2: ['r32float', 'rg32float', 'rgb32float-webgl', 'rgba32float'],
webgl: ['rgba8unorm', 'r32float', 'rg32float', 'rgb32float-webgl', 'rgba32float'],
webgpu: []
};

Expand All @@ -48,6 +35,41 @@ test('WebGLDevice#isTextureFormatSupported()', async t => {
t.end();
});

test('Texture#construct/delete', async t => {
for (const device of await getTestDevices()) {
const texture = device.createTexture({});
t.ok(texture instanceof Texture, 'Texture construction successful');
texture.destroy();
t.ok(texture instanceof Texture, 'Texture delete successful');
texture.destroy();
t.ok(texture instanceof Texture, 'Texture repeated delete successful');
}
t.end();
});

test('Texture#depth/stencil formats', async t => {
const DEPTH_STENCIL_FORMATS = ['depth16unorm', 'depth24plus', 'depth24plus-stencil8'];
for (const device of await getTestDevices()) {
for (const format of DEPTH_STENCIL_FORMATS) {
t.ok(device.isTextureFormatSupported(format), `${device.info.type} ${format} is supported`);
t.notOk(
device.isTextureFormatFilterable(format),
`${device.info.type} ${format} is not filterable`
);
const texture = device.createTexture({format});
t.ok(texture instanceof Texture, `Texture ${format} construction successful`);
}
}
t.end();
});

test.skip('Texture#format deduction', async t => {
for (const device of await getTestDevices()) {
testFormatDeduction(t, device);
}
t.end();
});

const DEFAULT_TEXTURE_DATA = new Uint8Array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]);
Expand Down Expand Up @@ -132,29 +154,29 @@ function testFormatDeduction(t, device: Device) {
}
}

test.skip('WebGL#Texture format deduction', async t => {
test.skip('Texture#format deduction', async t => {
for (const device of await getTestDevices()) {
testFormatDeduction(t, device);
}
t.end();
});

test.skip('WebGL#Texture format creation', async t => {
test.skip('Texture#format creation', async t => {
for (const device of await getTestDevices()) {
testFormatCreation(t, device);
}
t.end();
});

test.skip('WebGL#Texture format creation with data', async t => {
test.skip('Texture#format creation with data', async t => {
for (const device of await getTestDevices()) {
testFormatCreation(t, device, true);
}
t.end();
});

/*
test.skip('WebGL#Texture WebGL2 format creation', t => {
test.skip('Texture#WebGL2 format creation', t => {
for (const format in TEXTURE_FORMATS) {
}
Expand All @@ -168,7 +190,7 @@ test.skip('WebGL#Texture WebGL2 format creation', t => {
});
*/

test.skip('WebGL#Texture setParameters', t => {
test.skip('Texture#setParameters', t => {
const texture = webglDevice.createTexture({});
t.ok(texture instanceof Texture, 'Texture construction successful');

Expand Down Expand Up @@ -204,7 +226,7 @@ test.skip('WebGL2#Texture setParameters', t => {
t.end();
});

test.skip('WebGL#Texture NPOT Workaround: texture creation', t => {
test.skip('Texture#NPOT Workaround: texture creation', t => {
// Create NPOT texture with no parameters
let texture = webglDevice.createTexture({data: null, width: 500, height: 512});
t.ok(texture instanceof Texture, 'Texture construction successful');
Expand Down Expand Up @@ -243,7 +265,7 @@ test.skip('WebGL#Texture NPOT Workaround: texture creation', t => {
t.end();
});

test.skip('WebGL#Texture NPOT Workaround: setParameters', t => {
test.skip('Texture#NPOT Workaround: setParameters', t => {
// Create NPOT texture
const texture = webglDevice.createTexture({data: null, width: 100, height: 100});
t.ok(texture instanceof Texture, 'Texture construction successful');
Expand Down Expand Up @@ -453,7 +475,7 @@ export function testSamplerParameters({t, texture, parameters}) {

// 2D TEXTURES

test.skip('WebGL#Texture construct/delete', t => {
test.skip('Texture#construct/delete', t => {
t.throws(
// @ts-expect-error
() => new Texture(),
Expand All @@ -475,7 +497,7 @@ test.skip('WebGL#Texture construct/delete', t => {
t.end();
});

test.skip('WebGL#Texture async constructor', t => {
test.skip('Texture#async constructor', t => {
let texture = webglDevice.createTexture();
t.ok(texture instanceof Texture, 'Synchronous Texture construction successful');
t.equal(texture.loaded, true, 'Sync Texture marked as loaded');
Expand All @@ -498,7 +520,7 @@ test.skip('WebGL#Texture async constructor', t => {
loadCompleted(null);
});

test.skip('WebGL#Texture buffer update', t => {
test.skip('Texture#buffer update', t => {
let texture = webglDevice.createTexture();
t.ok(texture instanceof Texture, 'Texture construction successful');

Expand Down
Loading

0 comments on commit 3aae9a9

Please sign in to comment.