Commit 0add2092 authored by François Beaufort's avatar François Beaufort Committed by Commit Bot

[WebGPU] Add indirect draw / dispatch

This CL adds `dispatchIndirect` to GPUComputePassEncoder and
`drawIndirect` and `drawIndexedIndirect` to GPURenderPassEncoder.

Bug: 877147
Change-Id: Idd5344c112fc2df6564e5091ca0ef86dc8f8bcc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731113Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#683138}
parent a6cba1a8
......@@ -23,6 +23,7 @@ class GPUBufferUsage : public ScriptWrappable {
static constexpr uint32_t kVertex = 32;
static constexpr uint32_t kUniform = 64;
static constexpr uint32_t kStorage = 128;
static constexpr uint32_t kIndirect = 256;
private:
DISALLOW_COPY_AND_ASSIGN(GPUBufferUsage);
......
......@@ -17,4 +17,5 @@ typedef unsigned long GPUBufferUsageFlags;
const unsigned long VERTEX = 32;
const unsigned long UNIFORM = 64;
const unsigned long STORAGE = 128;
const unsigned long INDIRECT = 256;
};
......@@ -47,6 +47,12 @@ void GPUComputePassEncoder::dispatch(uint32_t x, uint32_t y, uint32_t z) {
GetProcs().computePassEncoderDispatch(GetHandle(), x, y, z);
}
void GPUComputePassEncoder::dispatchIndirect(GPUBuffer* indirectBuffer,
uint64_t indirectOffset) {
GetProcs().computePassEncoderDispatchIndirect(
GetHandle(), indirectBuffer->GetHandle(), indirectOffset);
}
void GPUComputePassEncoder::endPass() {
GetProcs().computePassEncoderEndPass(GetHandle());
}
......
......@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_COMPUTE_PASS_ENCODER_H_
#include "third_party/blink/renderer/modules/webgpu/dawn_object.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h"
namespace blink {
......@@ -29,6 +30,7 @@ class GPUComputePassEncoder : public DawnObject<DawnComputePassEncoder> {
const Vector<uint64_t>& dynamicOffsets);
void setPipeline(GPUComputePipeline* pipeline);
void dispatch(uint32_t x, uint32_t y, uint32_t z);
void dispatchIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset);
void endPass();
private:
......
......@@ -15,6 +15,8 @@
void dispatch(unsigned long x,
optional unsigned long y = 1,
optional unsigned long z = 1);
void dispatchIndirect(GPUBuffer indirectBuffer,
unsigned long long indirectOffset);
void endPass();
};
......@@ -113,6 +113,18 @@ void GPURenderPassEncoder::drawIndexed(uint32_t indexCount,
firstInstance);
}
void GPURenderPassEncoder::drawIndirect(GPUBuffer* indirectBuffer,
uint64_t indirectOffset) {
GetProcs().renderPassEncoderDrawIndirect(
GetHandle(), indirectBuffer->GetHandle(), indirectOffset);
}
void GPURenderPassEncoder::drawIndexedIndirect(GPUBuffer* indirectBuffer,
uint64_t indirectOffset) {
GetProcs().renderPassEncoderDrawIndexedIndirect(
GetHandle(), indirectBuffer->GetHandle(), indirectOffset);
}
void GPURenderPassEncoder::endPass() {
GetProcs().renderPassEncoderEndPass(GetHandle());
}
......
......@@ -55,6 +55,8 @@ class GPURenderPassEncoder : public DawnObject<DawnRenderPassEncoder> {
uint32_t firstIndex,
int32_t baseVertex,
uint32_t firstInstance);
void drawIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset);
void drawIndexedIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset);
void endPass();
......
......@@ -30,6 +30,10 @@
unsigned long firstIndex,
long baseVertex,
unsigned long firstInstance);
void drawIndirect(GPUBuffer indirectBuffer,
unsigned long long indirectOffset);
void drawIndexedIndirect(GPUBuffer indirectBuffer,
unsigned long long indirectOffset);
void endPass();
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment