GPUExternalTexture

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

Giao diện GPUExternalTexture của WebGPU API đại diện cho một đối tượng bao bọc chứa ảnh chụp nhanh HTMLVideoElement có thể được sử dụng như kết cấu trong các thao tác kết xuất GPU.

Đối tượng GPUExternalTexture được tạo bằng GPUDevice.importExternalTexture().

Thuộc tính phiên bản

label

Một chuỗi cung cấp nhãn có thể được sử dụng để nhận dạng đối tượng, ví dụ trong thông báo GPUError hoặc cảnh báo bảng điều khiển.

Ví dụ

Trong ví dụ Video Uploading của WebGPU Samples, một đối tượng GPUExternalTexture (được tạo qua lệnh gọi GPUDevice.importExternalTexture()) được sử dụng như giá trị resource trong mục nhập nhóm liên kết, được chỉ định khi tạo GPUBindGroup qua lệnh gọi GPUDevice.createBindGroup():

js
// …
const uniformBindGroup = device.createBindGroup({
  layout: pipeline.getBindGroupLayout(0),
  entries: [
    {
      binding: 1,
      resource: sampler,
    },
    {
      binding: 2,
      resource: device.importExternalTexture({
        source: video,
      }),
    },
  ],
});
// …

Thông số kỹ thuật

Specification
WebGPU
# gpuexternaltexture

Tương thích trình duyệt

Xem thêm