From e9ba23b51786b748ce9fde0c3ce68eecc3af8cff Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Wed, 24 Nov 2021 20:50:56 -0800 Subject: [PATCH 1/3] Define importing VideoFrame into WebGPU --- index.src.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/index.src.html b/index.src.html index c16f2faa..31c51c13 100644 --- a/index.src.html +++ b/index.src.html @@ -101,6 +101,14 @@ spec: visibility-state; urlPrefix: https://www.w3.org/TR/page-visibility/# type: enum-value; text: hidden; url: dom-visibilitystate-hidden + +spec: webgpu; urlPrefix: https://www.w3.org/TR/webgpu/# + type: interface; text: GPUExternalTexture; url: gpuexternaltexture + type: dictionary; text: GPUExternalTextureDescriptor; url: dictdef-gpuexternaltexturedescriptor + for: GPUExternalTextureDescriptor; + type: dict-member; text: source; url: dom-gpuexternaltexturedescriptor-source + for: GPUDevice; + type: method; text: importExternalTexture(); url: dom-gpudevice-importexternaltexture
@@ -3772,6 +3780,26 @@
 {{ImageBitmapOptions}} {{ImageBitmapOptions/colorSpaceConversion}}. Setting this
 value to "none" disables color space conversion.
 
+### WebGPU ### {#videoframe-webgpu}
+
+WebCodecs extends [[WebGPU]] to allow importing {{VideoFrame}} objects via
+{{GPUDevice/importExternalTexture()}}, producing opaque {{GPUExternalTexture}}
+objects, which can be read from WebGPU shaders.
+The definition of the {{GPUExternalTextureDescriptor/source}} member of
+{{GPUExternalTextureDescriptor}} is modified to allow {{VideoFrame}}:
+
+
+partial dictionary GPUExternalTextureDescriptor {
+    required (HTMLVideoElement or VideoFrame) source;
+};
+
+
+The lifetime of such a {{GPUExternalTexture}} object is implicitly tied to the
+lifetime of the source {{VideoFrame}} object.
+When the {{VideoFrame}} is [=Close VideoFrame|closed=] (implicitly or
+explicitly), the {{GPUExternalTexture}} is *destroyed*, so no further operations
+using it can be issued.
+
 VideoFrame CopyTo() Options {#videoframe-copyto-options}
 ------------------------------------------------------------
 Options to specify a rectangle of pixels to copy and the offset and stride of

From 4ff6aaaf87f7ae6f84bcee7caf6e85846bffb75b Mon Sep 17 00:00:00 2001
From: Kai Ninomiya 
Date: Wed, 1 Dec 2021 18:12:47 -0800
Subject: [PATCH 2/3] speculatively address comments

---
 index.src.html | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/index.src.html b/index.src.html
index 31c51c13..48d35482 100644
--- a/index.src.html
+++ b/index.src.html
@@ -3796,8 +3796,10 @@
 
 The lifetime of such a {{GPUExternalTexture}} object is implicitly tied to the
 lifetime of the source {{VideoFrame}} object.
-When the {{VideoFrame}} is [=Close VideoFrame|closed=] (implicitly or
-explicitly), the {{GPUExternalTexture}} is *destroyed*, so no further operations
+When the {{VideoFrame}} is [=Close VideoFrame|closed=]
+(e.g. via {{VideoFrame/close()}} or
+[[videoframe-transfer-serialization#|transferring the VideoFrame]]),
+the {{GPUExternalTexture}} is *destroyed*, so no further operations
 using it can be issued.
 
 VideoFrame CopyTo() Options {#videoframe-copyto-options}

From 690d53ba1be78ce0cf3ba251898d6fbc696e975b Mon Sep 17 00:00:00 2001
From: Kai Ninomiya 
Date: Wed, 8 Dec 2021 19:15:55 -0800
Subject: [PATCH 3/3] address comments (hopefully)

---
 index.src.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/index.src.html b/index.src.html
index 48d35482..8b6826bf 100644
--- a/index.src.html
+++ b/index.src.html
@@ -3788,7 +3788,7 @@
 The definition of the {{GPUExternalTextureDescriptor/source}} member of
 {{GPUExternalTextureDescriptor}} is modified to allow {{VideoFrame}}:
 
-
+<xmp class='idl'>
 partial dictionary GPUExternalTextureDescriptor {
     required (HTMLVideoElement or VideoFrame) source;
 };
@@ -3798,7 +3798,7 @@
 lifetime of the source {{VideoFrame}} object.
 When the {{VideoFrame}} is [=Close VideoFrame|closed=]
 (e.g. via {{VideoFrame/close()}} or
-[[videoframe-transfer-serialization#|transferring the VideoFrame]]),
+[[#videoframe-transfer-serialization|transferring the VideoFrame]]),
 the {{GPUExternalTexture}} is *destroyed*, so no further operations
 using it can be issued.