Skip to content

Commit 3147295

Browse files
committed
u64 instead of u16
1 parent 5ea64dc commit 3147295

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

wgpu-core/src/command/bundle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ struct State {
13251325
texture_memory_init_actions: Vec<TextureInitTrackerAction>,
13261326
next_dynamic_offset: usize,
13271327
binder: Binder,
1328-
immediate_slots_set: u16,
1328+
immediate_slots_set: u64,
13291329
}
13301330

13311331
impl State {

wgpu-core/src/command/compute.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ pub enum DispatchError {
129129
InvalidGroupSize { current: [u32; 3], limit: u32 },
130130
#[error(transparent)]
131131
BindingSizeTooSmall(#[from] LateMinBufferBindingSizeMismatch),
132-
#[error("Not all immediate data slots required by the pipeline have been set (required: 0x{required:04X}, set: 0x{set:04X})")]
133-
MissingImmediateData { required: u16, set: u16 },
132+
#[error("Not all immediate data slots required by the pipeline have been set (required: 0x{required:016X}, set: 0x{set:016X})")]
133+
MissingImmediateData { required: u64, set: u64 },
134134
}
135135

136136
impl WebGpuError for DispatchError {
@@ -264,7 +264,7 @@ struct State<'scope, 'snatch_guard, 'cmd_enc> {
264264

265265
immediates: Vec<u32>,
266266

267-
immediate_slots_set: u16,
267+
immediate_slots_set: u64,
268268

269269
intermediate_trackers: Tracker,
270270
}

wgpu-core/src/command/draw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ pub enum DrawError {
7575
highest_view_index: u32,
7676
max_multiviews: u32,
7777
},
78-
#[error("Not all immediate data slots required by the pipeline have been set (required: 0x{required:04X}, set: 0x{set:04X})")]
79-
MissingImmediateData { required: u16, set: u16 },
78+
#[error("Not all immediate data slots required by the pipeline have been set (required: 0x{required:016X}, set: 0x{set:016X})")]
79+
MissingImmediateData { required: u64, set: u64 },
8080
}
8181

8282
impl WebGpuError for DrawError {

wgpu-core/src/command/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ struct State<'scope, 'snatch_guard, 'cmd_enc> {
528528

529529
pass: pass::PassState<'scope, 'snatch_guard, 'cmd_enc>,
530530

531-
immediate_slots_set: u16,
531+
immediate_slots_set: u64,
532532

533533
active_occlusion_query: Option<(Arc<QuerySet>, u32)>,
534534
active_pipeline_statistics_query: Option<(Arc<QuerySet>, u32)>,

wgpu-core/src/device/resource.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4773,7 +4773,7 @@ impl Device {
47734773
.iter()
47744774
.filter_map(|sm| sm.interface.as_ref())
47754775
.map(|i| i.immediate_slots_required)
4776-
.fold(0u16, core::ops::BitOr::bitor);
4776+
.fold(0u64, core::ops::BitOr::bitor);
47774777

47784778
let pipeline = pipeline::RenderPipeline {
47794779
raw: ManuallyDrop::new(raw),

wgpu-core/src/immediates.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Returns the bitmask of slots covered by a `set_immediates(offset, size_bytes)` call.
2-
pub(crate) fn slots_for_range(offset: u32, size_bytes: u32) -> u16 {
3-
// u32 upcast to avoid overflow panic on n = 16
4-
let bits_below = |n: u32| ((1u32 << n.min(16)) - 1) as u16;
2+
pub(crate) fn slots_for_range(offset: u32, size_bytes: u32) -> u64 {
3+
// u128 upcast to avoid overflow panic on n = 64
4+
let bits_below = |n: u32| ((1u128 << n.min(64)) - 1) as u64;
55
let lo = offset / 4;
66
let hi = (offset + size_bytes).div_ceil(4);
77
bits_below(hi) - bits_below(lo)
@@ -13,10 +13,10 @@ pub(crate) fn slots_for_range(offset: u32, size_bytes: u32) -> u16 {
1313
/// For structs, gaps between members are padding and those slots need not be set.
1414
/// For scalars, vectors, and matrices, all slots in the span are required
1515
/// (the spec only defines padding exemptions at the struct-member level).
16-
pub(crate) fn slots_for_type(ty: &naga::TypeInner, gctx: naga::proc::GlobalCtx) -> u16 {
16+
pub(crate) fn slots_for_type(ty: &naga::TypeInner, gctx: naga::proc::GlobalCtx) -> u64 {
1717
match *ty {
1818
naga::TypeInner::Struct { ref members, .. } => {
19-
let mut mask: u16 = 0;
19+
let mut mask: u64 = 0;
2020
for member in members {
2121
let member_size = gctx.types[member.ty].inner.size(gctx);
2222
mask |= slots_for_range(member.offset, member_size);
@@ -41,7 +41,7 @@ fn immediate_type(module: &naga::Module) -> Option<&naga::TypeInner> {
4141

4242
/// Returns the required immediate slot bitmask for a naga module.
4343
/// Zero if the module has no `var<immediate>`.
44-
pub(crate) fn slots_for_module(module: &naga::Module) -> u16 {
44+
pub(crate) fn slots_for_module(module: &naga::Module) -> u64 {
4545
immediate_type(module).map_or(0, |ty| slots_for_type(ty, module.to_ctx()))
4646
}
4747

@@ -56,7 +56,7 @@ pub(crate) fn size_for_module(module: &naga::Module) -> u32 {
5656
mod tests {
5757
use super::slots_for_module;
5858

59-
fn immediate_slots(wgsl: &str) -> u16 {
59+
fn immediate_slots(wgsl: &str) -> u64 {
6060
slots_for_module(&naga::front::wgsl::parse_str(wgsl).unwrap())
6161
}
6262

wgpu-core/src/pipeline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ pub struct ComputePipeline {
278278
pub(crate) device: Arc<Device>,
279279
pub(crate) _shader_module: Arc<ShaderModule>,
280280
pub(crate) late_sized_buffer_groups: ArrayVec<LateSizedBufferGroup, { hal::MAX_BIND_GROUPS }>,
281-
pub(crate) immediate_slots_required: u16,
281+
pub(crate) immediate_slots_required: u64,
282282
/// The `label` from the descriptor used to create the resource.
283283
pub(crate) label: String,
284284
pub(crate) tracking_data: TrackingData,
@@ -816,7 +816,7 @@ pub struct RenderPipeline {
816816
pub(crate) strip_index_format: Option<wgt::IndexFormat>,
817817
pub(crate) vertex_steps: Vec<VertexStep>,
818818
pub(crate) late_sized_buffer_groups: ArrayVec<LateSizedBufferGroup, { hal::MAX_BIND_GROUPS }>,
819-
pub(crate) immediate_slots_required: u16,
819+
pub(crate) immediate_slots_required: u64,
820820
/// The `label` from the descriptor used to create the resource.
821821
pub(crate) label: String,
822822
pub(crate) tracking_data: TrackingData,

wgpu-core/src/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ pub struct Interface {
299299
limits: wgt::Limits,
300300
resources: naga::Arena<Resource>,
301301
entry_points: FastHashMap<(naga::ShaderStage, String), EntryPoint>,
302-
pub(crate) immediate_slots_required: u16,
302+
pub(crate) immediate_slots_required: u64,
303303
pub(crate) immediate_size: u32,
304304
}
305305

0 commit comments

Comments
 (0)