Open Bug 1616648 Opened 6 years ago Updated 2 years ago

Use uint64_t consistently for places where a length is expected in WebGPU internal API

Categories

(Core :: Graphics: WebGPU, defect, P5)

defect

Tracking

()

Tracking Status
thunderbird_esr60 --- unaffected
thunderbird_esr68 --- unaffected
firefox-esr68 --- unaffected
firefox76 --- disabled
firefox77 --- disabled
firefox78 --- disabled

People

(Reporter: kvark, Unassigned)

Details

Rust side currently uses usize, which appears to not having a direct counterpart in C++ land (uintptr_t can be larger, size_t can be smaller). We need to change all of these places to use uint64_t/u64 instead.

I do think generally we should default to uint64_t, since we still support some 32-bit systems, and the webidl bindings are all u64. (Also I haaaate having to think about how code may have different constraints on 32-bit vs 64-bit. GPU APIs have some support for u64 sizes in 32-bit binaries, so it's generally safest to just use u64, and rely on the compiler to show us where to put int-narrowing checks. (WebGL has this in C++, and as I understand it this is the default in Rust)

I suspect that we don't support (and will never see) a system where sizeof(void*) == sizeof(size_t) == sizeof(uintptr_t) is not true.

From the C++ side, I see size_t as the idiomatic choice for (unsigned) sizes, even though technically size_t and uintptr_t are equivalent for us.

In short, I think size_t is a better match for usize, but that we should indeed prefer u64 in most places.

Severity: normal → S4
Priority: P3 → P5
No longer blocks: webgpu-triage
You need to log in before you can comment on or make changes to this bug.