-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[webgpu] Implement draw API #7749
Conversation
7775e4b
to
efbccc5
Compare
} | ||
canvas2dContext.drawImage(canvasWebGPU, 0, 0); | ||
} | ||
backend.disposeData(output.dataId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering: is it possible that we meet this error since this texture is generated by gpuContext.getCurrentTexture() not textureManager
?
Cannot release a texture that was never provided by this texture manager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, this tensor should be marked as external.
@@ -19,6 +19,11 @@ import {backend_util, DataType, DataTypeMap, env, Rank, TensorInfo, util} from ' | |||
|
|||
import {symbolicallyComputeStrides} from './shader_util'; | |||
|
|||
export enum PixelsOpType { | |||
FROM_PIXELS, | |||
TO_PIXELS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep consistent, should we rename TO_PIXELS
to DRAW
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, PTAL
efbccc5
to
7a872e0
Compare
let gpuContext = canvas.getContext(backendName); | ||
let canvasWebGPU; | ||
if (!gpuContext) { | ||
canvasWebGPU = new OffscreenCanvas(width, height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forget one. Maybe we should cache the canvasWebGPU
if needed. Otherwise, it will be created every time when we call the Draw
API. And the configure
only needs to be called once if the canvas doesn't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canvasWebGPU is a fallback when a 2d canvas is used in webgpu context. To support the cache, we should use width, height as key, and I don't know when to free this cache, may be need a new API to free.
So I suggest donot support cache in this PR, maybe in next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the amazing implementation, LGTM except a nit.
7f22d76
to
23925aa
Compare
23925aa
to
c9ff688
Compare
@Linchenn, your comment is resolved, PTAL. |
LGTM, approved, thanks! |
To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.