这是indexloc提供的服务,不要输入任何密码
Skip to content

Image uploading is insufficiently expressive to be optimized #4185

@kainino0x

Description

@kainino0x

Currently, if you have a PNG or JPG for example, and want to upload it into WebGPU, you must upload through an ImageBitmap (... or a canvas, technically). The basic set of ways to upload are:

  • HTMLImageElement -> createImageBitmap -> copyExternalImageToTexture
    (Note image.decode is not useful here, because createImageBitmap is already asynchronous, and already expresses the intent that the image must be decoded.)
  • fetch -> blob -> createImageBitmap -> copyExternalImageToTexture

The core problem is, it's impossible to express the full intent of "I have a URL for an image and I want to copy it into a GPUTexture". The createImageBitmap step in particular cannot know that the goal is to copy the image into a GPUTexture and then throw it away and never use it again, so there's no real way to avoid an extra copy in the middle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiWebGPU APIapi-milestone-2-202502api issues that were in milestone 2 before we triaged milestone 1 on 2025-02-19

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions