GPURenderPassEncoder: phương thức executeBundles()

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.

Phương thức executeBundles() của giao diện GPURenderPassEncoder thực thi các lệnh đã được ghi lại trước đó vào GPURenderBundle được tham chiếu, như một phần của lần thực thi kết xuất này.

Note: Sau khi gọi executeBundles(), các bộ đệm đỉnh, bộ đệm chỉ mục, nhóm bind và pipeline hiện đang được đặt đều bị xóa, ngay cả khi không có gói nào thực sự được thực thi.

Cú pháp

js
executeBundles(bundles)

Tham số

bundles

Một mảng các đối tượng GPURenderBundle chứa các lệnh đã được ghi lại trước để thực thi.

Giá trị trả về

Không có (Undefined).

Xác thực

Các tiêu chí sau phải được đáp ứng khi gọi executeBundles(), nếu không GPUValidationError sẽ được tạo ra và GPURenderPassEncoder sẽ không hợp lệ.

Đối với mỗi GPURenderBundle:

Ví dụ

Trong ví dụ WebGPU Samples Animometer example, nhiều thao tác giống nhau được thực hiện trên nhiều đối tượng khác nhau đồng thời. executeBundles() được sử dụng để tái sử dụng công việc trên nhiều lần thực thi kết xuất nhằm cải thiện hiệu suất. Nghiên cứu danh sách mã ví dụ để có đầy đủ ngữ cảnh.

js
// …

return function doDraw(timestamp) {
  if (startTime === undefined) {
    startTime = timestamp;
  }
  uniformTime[0] = (timestamp - startTime) / 1000;
  device.queue.writeBuffer(uniformBuffer, timeOffset, uniformTime.buffer);

  renderPassDescriptor.colorAttachments[0].view = context
    .getCurrentTexture()
    .createView();

  const commandEncoder = device.createCommandEncoder();
  const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);

  if (settings.renderBundles) {
    passEncoder.executeBundles([renderBundle]);
  } else {
    recordRenderPass(passEncoder);
  }

  passEncoder.end();
  device.queue.submit([commandEncoder.finish()]);
};

// …

Thông số kỹ thuật

Specification
WebGPU
# dom-gpurenderpassencoder-executebundles

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

Xem thêm