Sitelet https://github.com/gpuweb/gpuweb/pull/285/files
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -736,22 +736,34 @@ Canvas Rendering and Swap Chain {#swapchain}
============================================

<script type=idl>
interface GPUCanvasContext {
// Calling configureSwapChain a second time invalidates the previous one,
// and all of the textures it’s produced.
GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor);

Promise<GPUTextureFormat> getSwapChainPreferredFormat(GPUDevice device);
}

dictionary GPUSwapChainDescriptor {
required GPUDevice device;
required ImageBitmapRenderingContext context;
required GPUTextureFormat format;
GPUTextureUsageFlags usage = GPUTextureUsage.OUTPUT_ATTACHMENT;
};

interface GPUSwapChain {
GPUTexture getCurrentTexture();
// Returns a new GPUTexture representing the next image in the swapchain.
//
// Sets the "has active swapchain image" flag.
// Throws an exception if the active was already set.
GPUTexture getNextTexture();

// Transfers the swapchain texture to an ImageBitmap. The GPUTexture
// becomes invalid. Throws an exception if the texture is not from this
// swapchain, or if it is invalid.
ImageBitmap transferToImageBitmap(GPUTexture texture);

// To present the ImageBitmap, use transferFromImageBitmap on the
// ImageBitmapRenderingContext that this GPUSwapChain was created from.
//
// Doing so closes the ImageBitmap, and unsets the "has active swapchain
// image" flag on the GPUSwapChain.

// Example:
// const texture = swapchain.getNextTexture();
// renderInto(texture);
// ibrc.transferFromImageBitmap(swapchain.transferToImageBitmap(texture));
};
</script>

Expand Down Expand Up @@ -790,6 +802,11 @@ interface GPUDevice {
GPUCommandEncoder createCommandEncoder(GPUCommandEncoderDescriptor descriptor);

GPUQueue getQueue();

// Calling configureSwapChain a second time invalidates/detaches the
// previous GPUSwapChain, and all of the swapchain images it has produced.
GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor);
Promise<GPUTextureFormat> getSwapChainPreferredFormat(ImageBitmapRenderingContext context);
};

dictionary GPUDeviceDescriptor {
Expand Down