Sitelet https://github.com/gpuweb/gpuweb/issues/250
Skip to content

Move createSwapChain from GPUDevice to GPUCanvasContext #250

Description

@beaufortfrancois

Creating a swap chain on the device doesn't make it clear from a web developer point of view that this is going to invalidate the previous one created on a context. I believe moving createSwapChain from GPUDevice to GPUCanvasContext would help a lot removing that potential confusion.

const canvas = document.querySelector('canvas');
const context = canvas.getContext('gpupresent');

// Before

const swapChainDescriptor = { context: context, format: 'bgra8unorm' };
const swapChain = device.createSwapChain(swapChainDescriptor);

const format = await device.getSwapChainPreferredFormat(context);

// After

const swapChainDescriptor = { device: device, format: 'bgra8unorm' };
const swapChain = context.createSwapChain(swapChainDescriptor);

const format = await context.getSwapChainPreferredFormat(device);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions