Skip to content

Commit 902def3

Browse files
committed
Bug 2031993 - Update wgpu to revision 0b4bdaf9cea213ce614405a834ff049b9dfba103. r=webgpu-reviewers,supply-chain-reviewers,webidl,smaug,aleiserson
Differential Revision: https://phabricator.services.mozilla.com/D294416
1 parent 4c12a81 commit 902def3

85 files changed

Lines changed: 1263 additions & 1228 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ git = "https://github.com/franziskuskiefer/cose-rust"
3535
rev = "43c22248d136c8b38fe42ea709d08da6355cf04b"
3636
replace-with = "vendored-sources"
3737

38-
[source."git+https://github.com/gfx-rs/wgpu?rev=f7b650d55c6c4a546db236a0779f18fe4ee7d82f"]
38+
[source."git+https://github.com/gfx-rs/wgpu?rev=0b4bdaf9cea213ce614405a834ff049b9dfba103"]
3939
git = "https://github.com/gfx-rs/wgpu"
40-
rev = "f7b650d55c6c4a546db236a0779f18fe4ee7d82f"
40+
rev = "0b4bdaf9cea213ce614405a834ff049b9dfba103"
4141
replace-with = "vendored-sources"
4242

4343
[source."git+https://github.com/glandium/allocator-api2?rev=ad5f3d56a5a4519eff52af4ff85293431466ef5c"]

Cargo.lock

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dom/webgpu/Device.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "mozilla/dom/VideoFrame.h"
4040
#include "mozilla/dom/WebGPUBinding.h"
4141
#include "mozilla/gfx/gfxVars.h"
42+
#include "mozilla/webgpu/ffi/wgpu.h"
4243
#include "nsGlobalWindowInner.h"
4344

4445
namespace mozilla::webgpu {
@@ -749,7 +750,7 @@ RawId CreateRenderPipelineImpl(RawId deviceId, WebGPUChild* aChild,
749750
const dom::GPURenderPipelineDescriptor& aDesc,
750751
bool isAsync) {
751752
// A bunch of stack locals that we can have pointers into
752-
nsTArray<ffi::WGPUVertexBufferLayout> vertexBuffers;
753+
nsTArray<ffi::WGPUFfiOption_VertexBufferLayout> vertexBuffers;
753754
nsTArray<ffi::WGPUVertexAttribute> vertexAttributes;
754755
ffi::WGPURenderPipelineDescriptor desc = {};
755756
nsCString vsEntry, fsEntry;
@@ -798,8 +799,12 @@ RawId CreateRenderPipelineImpl(RawId deviceId, WebGPUChild* aChild,
798799
}
799800

800801
for (const auto& vertex_desc : stage.mBuffers) {
801-
ffi::WGPUVertexBufferLayout vb_desc = {};
802-
if (!vertex_desc.IsNull()) {
802+
ffi::WGPUFfiOption_VertexBufferLayout opt_vb_desc = {};
803+
if (vertex_desc.IsNull()) {
804+
opt_vb_desc.tag =
805+
ffi::WGPUFfiOption_VertexBufferLayout_None_VertexBufferLayout;
806+
} else {
807+
ffi::WGPUVertexBufferLayout vb_desc = {};
803808
const auto& vd = vertex_desc.Value();
804809
vb_desc.array_stride = vd.mArrayStride;
805810
vb_desc.step_mode = ffi::WGPUVertexStepMode(vd.mStepMode);
@@ -812,14 +817,21 @@ RawId CreateRenderPipelineImpl(RawId deviceId, WebGPUChild* aChild,
812817
ad.shader_location = vat.mShaderLocation;
813818
vertexAttributes.AppendElement(ad);
814819
}
820+
opt_vb_desc.tag =
821+
ffi::WGPUFfiOption_VertexBufferLayout_Some_VertexBufferLayout;
822+
opt_vb_desc.some = vb_desc;
815823
}
816-
vertexBuffers.AppendElement(vb_desc);
824+
vertexBuffers.AppendElement(opt_vb_desc);
817825
}
818826
// Now patch up all the pointers to attribute lists.
819827
size_t numAttributes = 0;
820828
for (auto& vb_desc : vertexBuffers) {
821-
vb_desc.attributes.data = vertexAttributes.Elements() + numAttributes;
822-
numAttributes += vb_desc.attributes.length;
829+
if (vb_desc.tag ==
830+
ffi::WGPUFfiOption_VertexBufferLayout_Some_VertexBufferLayout) {
831+
vb_desc.some.attributes.data =
832+
vertexAttributes.Elements() + numAttributes;
833+
numAttributes += vb_desc.some.attributes.length;
834+
}
823835
}
824836

825837
vertexState.buffers = {vertexBuffers.Elements(), vertexBuffers.Length()};

dom/webgpu/RenderBundleEncoder.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,19 @@ void RenderBundleEncoder::SetIndexBuffer(
142142
}
143143

144144
void RenderBundleEncoder::SetVertexBuffer(
145-
uint32_t aSlot, const Buffer& aBuffer, uint64_t aOffset,
145+
uint32_t aSlot, const Buffer* const aBuffer, uint64_t aOffset,
146146
const dom::Optional<uint64_t>& aSize) {
147147
if (!mValid) {
148148
return;
149149
}
150-
mUsedBuffers.AppendElement(&aBuffer);
150+
RawId bufferId = 0;
151+
if (aBuffer) {
152+
mUsedBuffers.AppendElement(aBuffer);
153+
bufferId = aBuffer->GetId();
154+
}
151155
const uint64_t* sizeRef = aSize.WasPassed() ? &aSize.Value() : nullptr;
152-
ffi::wgpu_render_bundle_set_vertex_buffer(mEncoder.get(), aSlot,
153-
aBuffer.GetId(), aOffset, sizeRef);
156+
ffi::wgpu_render_bundle_set_vertex_buffer(mEncoder.get(), aSlot, bufferId,
157+
aOffset, sizeRef);
154158
}
155159

156160
void RenderBundleEncoder::Draw(uint32_t aVertexCount, uint32_t aInstanceCount,

dom/webgpu/RenderBundleEncoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class RenderBundleEncoder final : public nsWrapperCache,
7777
void SetIndexBuffer(const Buffer& aBuffer,
7878
const dom::GPUIndexFormat& aIndexFormat, uint64_t aOffset,
7979
const dom::Optional<uint64_t>& aSize);
80-
void SetVertexBuffer(uint32_t aSlot, const Buffer& aBuffer, uint64_t aOffset,
81-
const dom::Optional<uint64_t>& aSize);
80+
void SetVertexBuffer(uint32_t aSlot, const Buffer* const aBuffer,
81+
uint64_t aOffset, const dom::Optional<uint64_t>& aSize);
8282
void Draw(uint32_t aVertexCount, uint32_t aInstanceCount,
8383
uint32_t aFirstVertex, uint32_t aFirstInstance);
8484
void DrawIndexed(uint32_t aIndexCount, uint32_t aInstanceCount,

dom/webgpu/RenderPassEncoder.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,21 @@ void RenderPassEncoder::SetIndexBuffer(const Buffer& aBuffer,
333333
iformat, aOffset, sizeRef);
334334
}
335335

336-
void RenderPassEncoder::SetVertexBuffer(uint32_t aSlot, const Buffer& aBuffer,
336+
void RenderPassEncoder::SetVertexBuffer(uint32_t aSlot,
337+
const Buffer* const aBuffer,
337338
uint64_t aOffset,
338339
const dom::Optional<uint64_t>& aSize) {
339340
if (!mValid) {
340341
return;
341342
}
342-
mUsedBuffers.AppendElement(&aBuffer);
343-
343+
RawId bufferId = 0;
344+
if (aBuffer) {
345+
mUsedBuffers.AppendElement(aBuffer);
346+
bufferId = aBuffer->GetId();
347+
}
344348
const uint64_t* sizeRef = aSize.WasPassed() ? &aSize.Value() : nullptr;
345-
ffi::wgpu_recorded_render_pass_set_vertex_buffer(
346-
mPass.get(), aSlot, aBuffer.GetId(), aOffset, sizeRef);
349+
ffi::wgpu_recorded_render_pass_set_vertex_buffer(mPass.get(), aSlot, bufferId,
350+
aOffset, sizeRef);
347351
}
348352

349353
void RenderPassEncoder::Draw(uint32_t aVertexCount, uint32_t aInstanceCount,

dom/webgpu/RenderPassEncoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class RenderPassEncoder final : public nsWrapperCache,
8787
void SetIndexBuffer(const Buffer& aBuffer,
8888
const dom::GPUIndexFormat& aIndexFormat, uint64_t aOffset,
8989
const dom::Optional<uint64_t>& aSize);
90-
void SetVertexBuffer(uint32_t aSlot, const Buffer& aBuffer, uint64_t aOffset,
91-
const dom::Optional<uint64_t>& aSize);
90+
void SetVertexBuffer(uint32_t aSlot, const Buffer* const aBuffer,
91+
uint64_t aOffset, const dom::Optional<uint64_t>& aSize);
9292
void Draw(uint32_t aVertexCount, uint32_t aInstanceCount,
9393
uint32_t aFirstVertex, uint32_t aFirstInstance);
9494
void DrawIndexed(uint32_t aIndexCount, uint32_t aInstanceCount,

dom/webgpu/SupportedLimits.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ uint64_t GetLimit(const ffi::WGPULimits& limits, const Limit limit) {
3131
case Limit::MaxBindGroups:
3232
return limits.max_bind_groups;
3333
case Limit::MaxBindGroupsPlusVertexBuffers:
34-
// Not in ffi::WGPULimits, so synthesize:
35-
return GetLimit(limits, Limit::MaxBindGroups) +
36-
GetLimit(limits, Limit::MaxVertexBuffers);
34+
return limits.max_bind_groups_plus_vertex_buffers;
3735
case Limit::MaxBindingsPerBindGroup:
3836
return limits.max_bindings_per_bind_group;
3937
case Limit::MaxDynamicUniformBuffersPerPipelineLayout:
@@ -115,7 +113,7 @@ void SetLimit(ffi::WGPULimits* const limits, const Limit limit,
115113
limits->max_bind_groups = val;
116114
return;
117115
case Limit::MaxBindGroupsPlusVertexBuffers:
118-
// TODO(bug 1967020, sort of): Not in ffi::WGPULimits.
116+
limits->max_bind_groups_plus_vertex_buffers = val;
119117
return;
120118
case Limit::MaxBindingsPerBindGroup:
121119
limits->max_bindings_per_bind_group = val;

dom/webidl/WebGPU.webidl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ interface mixin GPURenderCommandsMixin {
11801180
undefined setPipeline(GPURenderPipeline pipeline);
11811181

11821182
undefined setIndexBuffer(GPUBuffer buffer, GPUIndexFormat indexFormat, optional GPUSize64 offset = 0, optional GPUSize64 size);
1183-
undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size);
1183+
undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer? buffer, optional GPUSize64 offset = 0, optional GPUSize64 size);
11841184

11851185
undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1,
11861186
optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0);

gfx/wgpu_bindings/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,40 @@ default = []
1717
[dependencies.wgc]
1818
package = "wgpu-core"
1919
git = "https://github.com/gfx-rs/wgpu"
20-
rev = "f7b650d55c6c4a546db236a0779f18fe4ee7d82f"
20+
rev = "0b4bdaf9cea213ce614405a834ff049b9dfba103"
2121
features = ["serde", "trace", "strict_asserts", "wgsl", "api_log_info"]
2222

2323
# We want the wgpu-core Metal backend on macOS and iOS.
2424
# (We should consider also enabling "vulkan" for Vulkan Portability.)
2525
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
2626
package = "wgpu-core"
2727
git = "https://github.com/gfx-rs/wgpu"
28-
rev = "f7b650d55c6c4a546db236a0779f18fe4ee7d82f"
28+
rev = "0b4bdaf9cea213ce614405a834ff049b9dfba103"
2929
features = ["metal"]
3030

3131
# We want the wgpu-core Direct3D backends on Windows.
3232
[target.'cfg(windows)'.dependencies.wgc]
3333
package = "wgpu-core"
3434
git = "https://github.com/gfx-rs/wgpu"
35-
rev = "f7b650d55c6c4a546db236a0779f18fe4ee7d82f"
35+
rev = "0b4bdaf9cea213ce614405a834ff049b9dfba103"
3636
features = ["dx12"]
3737

3838
# We want the wgpu-core Vulkan backend on Linux and Windows.
3939
[target.'cfg(any(windows, all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies.wgc]
4040
package = "wgpu-core"
4141
git = "https://github.com/gfx-rs/wgpu"
42-
rev = "f7b650d55c6c4a546db236a0779f18fe4ee7d82f"
42+
rev = "0b4bdaf9cea213ce614405a834ff049b9dfba103"
4343
features = ["vulkan"]
4444

4545
[dependencies.wgt]
4646
package = "wgpu-types"
4747
git = "https://github.com/gfx-rs/wgpu"
48-
rev = "f7b650d55c6c4a546db236a0779f18fe4ee7d82f"
48+
rev = "0b4bdaf9cea213ce614405a834ff049b9dfba103"
4949

5050
[dependencies.wgh]
5151
package = "wgpu-hal"
5252
git = "https://github.com/gfx-rs/wgpu"
53-
rev = "f7b650d55c6c4a546db236a0779f18fe4ee7d82f"
53+
rev = "0b4bdaf9cea213ce614405a834ff049b9dfba103"
5454
features = ["device_lost_panic", "internal_error_panic"]
5555

5656
[target.'cfg(windows)'.dependencies]

0 commit comments

Comments
 (0)