Skip to content

Make copyExternalImageToTexture orientation configurable - #2158

Closed
kainino0x wants to merge 1 commit into
gpuweb:mainfrom
kainino0x:orientation
Closed

kainino0x wants to merge 1 commit into
gpuweb:mainfrom
kainino0x:orientation

Conversation

@kainino0x

@kainino0x kainino0x commented Oct 1, 2021 •

Copy link
Copy Markdown
Contributor

Note that importExternalTexture is not made configurable.

  • Assuming zero-copy or non-flipped sources, there is no cost to a y-flip because it just changes the sampling coordinates, and users can trivially y-flip inside their shader.
  • I think videos are probably always non-flipped, so it's probably not needed right now? If we add canvas support to importExternalTexture (Allow importing canvases as GPUExternalTextures #1670), then in the non-zero-copy case, it can still improve performance for the same reason, so we could add it.

Fixes #2110


Preview | Diff

Comment thread spec/index.bs
<script type=idl>
dictionary GPUImageCopyExternalImage {
required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source;
boolean originBottomLeft = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't followed all the technical detail on why it's needed, but if it is needed, why are we not making it a proper enum (even if with only 2 variants)? If I see originBottomLeft = true, it's non-ambiguous. But seeing originBottomLeft = false may be.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is closed now, but for future reference in case we revisit this:

I considered making this an enum but there are really only two options (the GL way, and the normal way). Other places (webgl, imagebitmap) call this "flip y", which is something you do in an operation, not something you tag an image with. (Internally in Chromium we also have topleft/bottomleft origins.) Maybe "flip y" would make the most sense though since this is really part of the operation and not the tagging. (If it were tagging it would be in GPUImageCopyTextureTagged, not GPUImageCopyExternalImage.)

Initially I was going to make it origin: "top-left" but we already have a field called origin.

@kainino0x

Copy link
Copy Markdown
Contributor Author

Resolution: No need to do this

@kainino0x kainino0x closed this Oct 4, 2021
@kainino0x
kainino0x deleted the orientation branch October 4, 2021 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Which corner is the origin of a copyExternalImageToTexture?

2 participants