node: Support sparse vertex buffer layouts

Bug: dawn:1000
Change-Id: I616369acdf5c9d883da8d0da292aa1b3f4a77250
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112021
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Corentin Wallez 2022-12-02 15:35:14 +00:00 committed by Dawn LUCI CQ
parent 89b2e10eac
commit 63a67a7218
1 changed files with 19 additions and 3 deletions

View File

@ -1148,9 +1148,25 @@ bool Converter::Convert(wgpu::VertexBufferLayout& out, const interop::GPUVertexB
bool Converter::Convert(wgpu::VertexState& out, const interop::GPUVertexState& in) {
out = {};
return Convert(out.module, in.module) && Convert(out.buffers, out.bufferCount, in.buffers) &&
Convert(out.entryPoint, in.entryPoint) &&
Convert(out.constants, out.constantCount, in.constants);
wgpu::VertexBufferLayout* outBuffers = nullptr;
if (!Convert(out.module, in.module) || //
!Convert(outBuffers, out.bufferCount, in.buffers) || //
!Convert(out.entryPoint, in.entryPoint) || //
!Convert(out.constants, out.constantCount, in.constants)) {
return false;
}
// Patch up the unused vertex buffer layouts to use wgpu::VertexStepMode::VertexBufferNotUsed.
// The converter for optional value will have put the default value of wgpu::VertexBufferLayout
// that has wgpu::VertexStepMode::Vertex.
out.buffers = outBuffers;
for (size_t i = 0; i < in.buffers.size(); i++) {
if (!in.buffers[i].has_value()) {
outBuffers[i].stepMode = wgpu::VertexStepMode::VertexBufferNotUsed;
}
}
return true;
}
bool Converter::Convert(wgpu::VertexStepMode& out, const interop::GPUVertexStepMode& in) {