Skip to content

Commit b37f050

Browse files
Deploying to master from @ gfx-rs/wgpu@ee35b0e 🚀
1 parent 3cc5fe6 commit b37f050

File tree

428 files changed

+1769
-1371
lines changed

Some content is hidden

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

428 files changed

+1769
-1371
lines changed

doc/search-index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/src/wgpu_core/binding_model.rs.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,16 @@
10081008
<a href="#1007" id="1007">1007</a>
10091009
<a href="#1008" id="1008">1008</a>
10101010
<a href="#1009" id="1009">1009</a>
1011+
<a href="#1010" id="1010">1010</a>
1012+
<a href="#1011" id="1011">1011</a>
1013+
<a href="#1012" id="1012">1012</a>
1014+
<a href="#1013" id="1013">1013</a>
1015+
<a href="#1014" id="1014">1014</a>
1016+
<a href="#1015" id="1015">1015</a>
1017+
<a href="#1016" id="1016">1016</a>
1018+
<a href="#1017" id="1017">1017</a>
1019+
<a href="#1018" id="1018">1018</a>
1020+
<a href="#1019" id="1019">1019</a>
10111021
</pre></div><pre class="rust"><code><span class="kw">use crate</span>::{
10121022
device::{
10131023
bgl, Device, DeviceError, MissingDownlevelFlags, MissingFeatures, SHADER_STAGE_COUNT,
@@ -1894,6 +1904,16 @@
18941904
}
18951905
}
18961906

1907+
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>buffer_binding_type_bounds_check_alignment(
1908+
alignments: <span class="kw-2">&amp;</span>hal::Alignments,
1909+
binding_type: wgt::BufferBindingType,
1910+
) -&gt; wgt::BufferAddress {
1911+
<span class="kw">match </span>binding_type {
1912+
wgt::BufferBindingType::Uniform =&gt; alignments.uniform_bounds_check_alignment.get(),
1913+
wgt::BufferBindingType::Storage { .. } =&gt; wgt::COPY_BUFFER_ALIGNMENT,
1914+
}
1915+
}
1916+
18971917
<span class="attr">#[derive(Debug)]
18981918
</span><span class="kw">pub struct </span>BindGroup {
18991919
<span class="kw">pub</span>(<span class="kw">crate</span>) raw: Snatchable&lt;Box&lt;<span class="kw">dyn </span>hal::DynBindGroup&gt;&gt;,

doc/src/wgpu_core/device/global.rs.html

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,6 +2473,9 @@
24732473
<a href="#2472" id="2472">2472</a>
24742474
<a href="#2473" id="2473">2473</a>
24752475
<a href="#2474" id="2474">2474</a>
2476+
<a href="#2475" id="2475">2475</a>
2477+
<a href="#2476" id="2476">2476</a>
2478+
<a href="#2477" id="2477">2477</a>
24762479
</pre></div><pre class="rust"><code><span class="attr">#[cfg(feature = <span class="string">"trace"</span>)]
24772480
</span><span class="kw">use </span><span class="kw">crate</span>::device::trace;
24782481
<span class="kw">use crate</span>::{
@@ -3270,14 +3273,14 @@
32703273
<span class="prelude-val">Err</span>(..) =&gt; <span class="kw">break </span><span class="lifetime">'error </span>binding_model::CreateBindGroupError::InvalidLayout,
32713274
};
32723275

3273-
<span class="kw">fn </span>map_entry&lt;<span class="lifetime">'a</span>&gt;(
3276+
<span class="kw">fn </span>resolve_entry&lt;<span class="lifetime">'a</span>&gt;(
32743277
e: <span class="kw-2">&amp;</span>BindGroupEntry&lt;<span class="lifetime">'a</span>&gt;,
32753278
buffer_storage: <span class="kw-2">&amp;</span>Storage&lt;resource::Buffer&gt;,
32763279
sampler_storage: <span class="kw-2">&amp;</span>Storage&lt;resource::Sampler&gt;,
32773280
texture_view_storage: <span class="kw-2">&amp;</span>Storage&lt;resource::TextureView&gt;,
32783281
) -&gt; <span class="prelude-ty">Result</span>&lt;ResolvedBindGroupEntry&lt;<span class="lifetime">'a</span>&gt;, binding_model::CreateBindGroupError&gt;
32793282
{
3280-
<span class="kw">let </span>map_buffer = |bb: <span class="kw-2">&amp;</span>BufferBinding| {
3283+
<span class="kw">let </span>resolve_buffer = |bb: <span class="kw-2">&amp;</span>BufferBinding| {
32813284
buffer_storage
32823285
.get_owned(bb.buffer_id)
32833286
.map(|buffer| ResolvedBufferBinding {
@@ -3289,42 +3292,45 @@
32893292
binding_model::CreateBindGroupError::InvalidBufferId(bb.buffer_id)
32903293
})
32913294
};
3292-
<span class="kw">let </span>map_sampler = |id: <span class="kw-2">&amp;</span>id::SamplerId| {
3295+
<span class="kw">let </span>resolve_sampler = |id: <span class="kw-2">&amp;</span>id::SamplerId| {
32933296
sampler_storage
32943297
.get_owned(<span class="kw-2">*</span>id)
32953298
.map_err(|<span class="kw">_</span>| binding_model::CreateBindGroupError::InvalidSamplerId(<span class="kw-2">*</span>id))
32963299
};
3297-
<span class="kw">let </span>map_view = |id: <span class="kw-2">&amp;</span>id::TextureViewId| {
3300+
<span class="kw">let </span>resolve_view = |id: <span class="kw-2">&amp;</span>id::TextureViewId| {
32983301
texture_view_storage
32993302
.get_owned(<span class="kw-2">*</span>id)
33003303
.map_err(|<span class="kw">_</span>| binding_model::CreateBindGroupError::InvalidTextureViewId(<span class="kw-2">*</span>id))
33013304
};
33023305
<span class="kw">let </span>resource = <span class="kw">match </span>e.resource {
33033306
BindingResource::Buffer(<span class="kw-2">ref </span>buffer) =&gt; {
3304-
ResolvedBindingResource::Buffer(map_buffer(buffer)<span class="question-mark">?</span>)
3307+
ResolvedBindingResource::Buffer(resolve_buffer(buffer)<span class="question-mark">?</span>)
33053308
}
33063309
BindingResource::BufferArray(<span class="kw-2">ref </span>buffers) =&gt; {
33073310
<span class="kw">let </span>buffers = buffers
33083311
.iter()
3309-
.map(map_buffer)
3312+
.map(resolve_buffer)
33103313
.collect::&lt;<span class="prelude-ty">Result</span>&lt;Vec&lt;<span class="kw">_</span>&gt;, <span class="kw">_</span>&gt;&gt;()<span class="question-mark">?</span>;
33113314
ResolvedBindingResource::BufferArray(Cow::Owned(buffers))
33123315
}
33133316
BindingResource::Sampler(<span class="kw-2">ref </span>sampler) =&gt; {
3314-
ResolvedBindingResource::Sampler(map_sampler(sampler)<span class="question-mark">?</span>)
3317+
ResolvedBindingResource::Sampler(resolve_sampler(sampler)<span class="question-mark">?</span>)
33153318
}
33163319
BindingResource::SamplerArray(<span class="kw-2">ref </span>samplers) =&gt; {
33173320
<span class="kw">let </span>samplers = samplers
33183321
.iter()
3319-
.map(map_sampler)
3322+
.map(resolve_sampler)
33203323
.collect::&lt;<span class="prelude-ty">Result</span>&lt;Vec&lt;<span class="kw">_</span>&gt;, <span class="kw">_</span>&gt;&gt;()<span class="question-mark">?</span>;
33213324
ResolvedBindingResource::SamplerArray(Cow::Owned(samplers))
33223325
}
33233326
BindingResource::TextureView(<span class="kw-2">ref </span>view) =&gt; {
3324-
ResolvedBindingResource::TextureView(map_view(view)<span class="question-mark">?</span>)
3327+
ResolvedBindingResource::TextureView(resolve_view(view)<span class="question-mark">?</span>)
33253328
}
33263329
BindingResource::TextureViewArray(<span class="kw-2">ref </span>views) =&gt; {
3327-
<span class="kw">let </span>views = views.iter().map(map_view).collect::&lt;<span class="prelude-ty">Result</span>&lt;Vec&lt;<span class="kw">_</span>&gt;, <span class="kw">_</span>&gt;&gt;()<span class="question-mark">?</span>;
3330+
<span class="kw">let </span>views = views
3331+
.iter()
3332+
.map(resolve_view)
3333+
.collect::&lt;<span class="prelude-ty">Result</span>&lt;Vec&lt;<span class="kw">_</span>&gt;, <span class="kw">_</span>&gt;&gt;()<span class="question-mark">?</span>;
33283334
ResolvedBindingResource::TextureViewArray(Cow::Owned(views))
33293335
}
33303336
};
@@ -3340,7 +3346,7 @@
33403346
<span class="kw">let </span>sampler_guard = hub.samplers.read();
33413347
desc.entries
33423348
.iter()
3343-
.map(|e| map_entry(e, <span class="kw-2">&amp;</span>buffer_guard, <span class="kw-2">&amp;</span>sampler_guard, <span class="kw-2">&amp;</span>texture_view_guard))
3349+
.map(|e| resolve_entry(e, <span class="kw-2">&amp;</span>buffer_guard, <span class="kw-2">&amp;</span>sampler_guard, <span class="kw-2">&amp;</span>texture_view_guard))
33443350
.collect::&lt;<span class="prelude-ty">Result</span>&lt;Vec&lt;<span class="kw">_</span>&gt;, <span class="kw">_</span>&gt;&gt;()
33453351
};
33463352
<span class="kw">let </span>entries = <span class="kw">match </span>entries {

doc/src/wgpu_core/device/resource.rs.html

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,6 +3664,13 @@
36643664
<a href="#3663" id="3663">3663</a>
36653665
<a href="#3664" id="3664">3664</a>
36663666
<a href="#3665" id="3665">3665</a>
3667+
<a href="#3666" id="3666">3666</a>
3668+
<a href="#3667" id="3667">3667</a>
3669+
<a href="#3668" id="3668">3668</a>
3670+
<a href="#3669" id="3669">3669</a>
3671+
<a href="#3670" id="3670">3670</a>
3672+
<a href="#3671" id="3671">3671</a>
3673+
<a href="#3672" id="3672">3672</a>
36673674
</pre></div><pre class="rust"><code><span class="attr">#[cfg(feature = <span class="string">"trace"</span>)]
36683675
</span><span class="kw">use </span><span class="kw">crate</span>::device::trace;
36693676
<span class="kw">use crate</span>::{
@@ -3705,7 +3712,9 @@
37053712

37063713
<span class="kw">use </span>smallvec::SmallVec;
37073714
<span class="kw">use </span>thiserror::Error;
3708-
<span class="kw">use </span>wgt::{DeviceLostReason, TextureFormat, TextureSampleType, TextureViewDimension};
3715+
<span class="kw">use </span>wgt::{
3716+
math::align_to, DeviceLostReason, TextureFormat, TextureSampleType, TextureViewDimension,
3717+
};
37093718

37103719
<span class="kw">use </span>std::{
37113720
borrow::Cow,
@@ -5295,7 +5304,7 @@
52955304

52965305
<span class="doccomment">/// Generate information about late-validated buffer bindings for pipelines.
52975306
</span><span class="comment">//TODO: should this be combined with `get_introspection_bind_group_layouts` in some way?
5298-
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>make_late_sized_buffer_groups(
5307+
</span><span class="kw">fn </span>make_late_sized_buffer_groups(
52995308
shader_binding_sizes: <span class="kw-2">&amp;</span>FastHashMap&lt;naga::ResourceBinding, wgt::BufferSize&gt;,
53005309
layout: <span class="kw-2">&amp;</span>binding_model::PipelineLayout,
53015310
) -&gt; ArrayVec&lt;pipeline::LateSizedBufferGroup, { hal::MAX_BIND_GROUPS }&gt; {
@@ -5547,16 +5556,15 @@
55475556
<span class="prelude-val">Ok</span>(bgl)
55485557
}
55495558

5550-
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>create_buffer_binding&lt;<span class="lifetime">'a</span>&gt;(
5551-
<span class="self">self</span>: <span class="kw-2">&amp;</span>Arc&lt;<span class="self">Self</span>&gt;,
5559+
<span class="kw">fn </span>create_buffer_binding&lt;<span class="lifetime">'a</span>&gt;(
5560+
<span class="kw-2">&amp;</span><span class="self">self</span>,
55525561
bb: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>binding_model::ResolvedBufferBinding,
55535562
binding: u32,
55545563
decl: <span class="kw-2">&amp;</span>wgt::BindGroupLayoutEntry,
55555564
used_buffer_ranges: <span class="kw-2">&amp;mut </span>Vec&lt;BufferInitTrackerAction&gt;,
55565565
dynamic_binding_info: <span class="kw-2">&amp;mut </span>Vec&lt;binding_model::BindGroupDynamicBindingData&gt;,
55575566
late_buffer_binding_sizes: <span class="kw-2">&amp;mut </span>FastHashMap&lt;u32, wgt::BufferSize&gt;,
55585567
used: <span class="kw-2">&amp;mut </span>BindGroupStates,
5559-
limits: <span class="kw-2">&amp;</span>wgt::Limits,
55605568
snatch_guard: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>SnatchGuard&lt;<span class="lifetime">'a</span>&gt;,
55615569
) -&gt; <span class="prelude-ty">Result</span>&lt;hal::BufferBinding&lt;<span class="lifetime">'a</span>, <span class="kw">dyn </span>hal::DynBuffer&gt;, binding_model::CreateBindGroupError&gt;
55625570
{
@@ -5581,7 +5589,7 @@
55815589
wgt::BufferBindingType::Uniform =&gt; (
55825590
wgt::BufferUsages::UNIFORM,
55835591
hal::BufferUses::UNIFORM,
5584-
limits.max_uniform_buffer_binding_size,
5592+
<span class="self">self</span>.limits.max_uniform_buffer_binding_size,
55855593
),
55865594
wgt::BufferBindingType::Storage { read_only } =&gt; (
55875595
wgt::BufferUsages::STORAGE,
@@ -5590,12 +5598,12 @@
55905598
} <span class="kw">else </span>{
55915599
hal::BufferUses::STORAGE_READ_WRITE
55925600
},
5593-
limits.max_storage_buffer_binding_size,
5601+
<span class="self">self</span>.limits.max_storage_buffer_binding_size,
55945602
),
55955603
};
55965604

55975605
<span class="kw">let </span>(align, align_limit_name) =
5598-
binding_model::buffer_binding_type_alignment(limits, binding_ty);
5606+
binding_model::buffer_binding_type_alignment(<span class="kw-2">&amp;</span><span class="self">self</span>.limits, binding_ty);
55995607
<span class="kw">if </span>bb.offset % align <span class="kw">as </span>u64 != <span class="number">0 </span>{
56005608
<span class="kw">return </span><span class="prelude-val">Err</span>(Error::UnalignedBufferOffset(
56015609
bb.offset,
@@ -5671,10 +5679,21 @@
56715679
late_buffer_binding_sizes.insert(binding, late_size);
56725680
}
56735681

5674-
<span class="macro">assert_eq!</span>(bb.offset % wgt::COPY_BUFFER_ALIGNMENT, <span class="number">0</span>);
5682+
<span class="comment">// This was checked against the device's alignment requirements above,
5683+
// which should always be a multiple of `COPY_BUFFER_ALIGNMENT`.
5684+
</span><span class="macro">assert_eq!</span>(bb.offset % wgt::COPY_BUFFER_ALIGNMENT, <span class="number">0</span>);
5685+
5686+
<span class="comment">// `wgpu_hal` only restricts shader access to bound buffer regions with
5687+
// a certain resolution. For the sake of lazy initialization, round up
5688+
// the size of the bound range to reflect how much of the buffer is
5689+
// actually going to be visible to the shader.
5690+
</span><span class="kw">let </span>bounds_check_alignment =
5691+
binding_model::buffer_binding_type_bounds_check_alignment(<span class="kw-2">&amp;</span><span class="self">self</span>.alignments, binding_ty);
5692+
<span class="kw">let </span>visible_size = align_to(bind_size, bounds_check_alignment);
5693+
56755694
used_buffer_ranges.extend(buffer.initialization_status.read().create_action(
56765695
buffer,
5677-
bb.offset..bb.offset + bind_size,
5696+
bb.offset..bb.offset + visible_size,
56785697
MemoryInitKind::NeedsInitializedMemory,
56795698
));
56805699

@@ -5686,7 +5705,7 @@
56865705
}
56875706

56885707
<span class="kw">fn </span>create_sampler_binding&lt;<span class="lifetime">'a</span>&gt;(
5689-
<span class="self">self</span>: <span class="kw-2">&amp;</span>Arc&lt;<span class="self">Self</span>&gt;,
5708+
<span class="kw-2">&amp;</span><span class="self">self</span>,
56905709
used: <span class="kw-2">&amp;mut </span>BindGroupStates,
56915710
binding: u32,
56925711
decl: <span class="kw-2">&amp;</span>wgt::BindGroupLayoutEntry,
@@ -5734,8 +5753,8 @@
57345753
<span class="prelude-val">Ok</span>(sampler.raw())
57355754
}
57365755

5737-
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>create_texture_binding&lt;<span class="lifetime">'a</span>&gt;(
5738-
<span class="self">self</span>: <span class="kw-2">&amp;</span>Arc&lt;<span class="self">Self</span>&gt;,
5756+
<span class="kw">fn </span>create_texture_binding&lt;<span class="lifetime">'a</span>&gt;(
5757+
<span class="kw-2">&amp;</span><span class="self">self</span>,
57395758
binding: u32,
57405759
decl: <span class="kw-2">&amp;</span>wgt::BindGroupLayoutEntry,
57415760
view: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>Arc&lt;TextureView&gt;,
@@ -5833,7 +5852,6 @@
58335852
<span class="kw-2">&amp;mut </span>dynamic_binding_info,
58345853
<span class="kw-2">&amp;mut </span>late_buffer_binding_sizes,
58355854
<span class="kw-2">&amp;mut </span>used,
5836-
<span class="kw-2">&amp;</span><span class="self">self</span>.limits,
58375855
<span class="kw-2">&amp;</span>snatch_guard,
58385856
)<span class="question-mark">?</span>;
58395857

@@ -5855,7 +5873,6 @@
58555873
<span class="kw-2">&amp;mut </span>dynamic_binding_info,
58565874
<span class="kw-2">&amp;mut </span>late_buffer_binding_sizes,
58575875
<span class="kw-2">&amp;mut </span>used,
5858-
<span class="kw-2">&amp;</span><span class="self">self</span>.limits,
58595876
<span class="kw-2">&amp;</span>snatch_guard,
58605877
)<span class="question-mark">?</span>;
58615878
hal_buffers.push(bb);
@@ -5991,7 +6008,7 @@
59916008
<span class="prelude-val">Ok</span>(bind_group)
59926009
}
59936010

5994-
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>check_array_binding(
6011+
<span class="kw">fn </span>check_array_binding(
59956012
features: wgt::Features,
59966013
count: <span class="prelude-ty">Option</span>&lt;NonZeroU32&gt;,
59976014
num_bindings: usize,
@@ -6024,8 +6041,8 @@
60246041
<span class="prelude-val">Ok</span>(())
60256042
}
60266043

6027-
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>texture_use_parameters(
6028-
<span class="self">self</span>: <span class="kw-2">&amp;</span>Arc&lt;<span class="self">Self</span>&gt;,
6044+
<span class="kw">fn </span>texture_use_parameters(
6045+
<span class="kw-2">&amp;</span><span class="self">self</span>,
60296046
binding: u32,
60306047
decl: <span class="kw-2">&amp;</span>wgt::BindGroupLayoutEntry,
60316048
view: <span class="kw-2">&amp;</span>TextureView,
@@ -7115,10 +7132,7 @@
71157132
<span class="prelude-val">Ok</span>(cache)
71167133
}
71177134

7118-
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>get_texture_format_features(
7119-
<span class="kw-2">&amp;</span><span class="self">self</span>,
7120-
format: TextureFormat,
7121-
) -&gt; wgt::TextureFormatFeatures {
7135+
<span class="kw">fn </span>get_texture_format_features(<span class="kw-2">&amp;</span><span class="self">self</span>, format: TextureFormat) -&gt; wgt::TextureFormatFeatures {
71227136
<span class="comment">// Variant of adapter.get_texture_format_features that takes device features into account
71237137
</span><span class="kw">use </span>wgt::TextureFormatFeatureFlags <span class="kw">as </span>tfsc;
71247138
<span class="kw">let </span><span class="kw-2">mut </span>format_features = <span class="self">self</span>.adapter.get_texture_format_features(format);
@@ -7132,7 +7146,7 @@
71327146
format_features
71337147
}
71347148

7135-
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>describe_format_features(
7149+
<span class="kw">fn </span>describe_format_features(
71367150
<span class="kw-2">&amp;</span><span class="self">self</span>,
71377151
format: TextureFormat,
71387152
) -&gt; <span class="prelude-ty">Result</span>&lt;wgt::TextureFormatFeatures, MissingFeatures&gt; {

doc/src/wgpu_core/resource.rs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,8 +1946,8 @@
19461946
}
19471947
}
19481948

1949-
<span class="kw">fn </span>same_device(<span class="kw-2">&amp;</span><span class="self">self</span>, device: <span class="kw-2">&amp;</span>Arc&lt;Device&gt;) -&gt; <span class="prelude-ty">Result</span>&lt;(), DeviceError&gt; {
1950-
<span class="kw">if </span>Arc::ptr_eq(<span class="self">self</span>.device(), device) {
1949+
<span class="kw">fn </span>same_device(<span class="kw-2">&amp;</span><span class="self">self</span>, device: <span class="kw-2">&amp;</span>Device) -&gt; <span class="prelude-ty">Result</span>&lt;(), DeviceError&gt; {
1950+
<span class="kw">if </span>std::ptr::eq(<span class="kw-2">&amp;**</span><span class="self">self</span>.device(), device) {
19511951
<span class="prelude-val">Ok</span>(())
19521952
} <span class="kw">else </span>{
19531953
<span class="prelude-val">Err</span>(DeviceError::DeviceMismatch(Box::new(DeviceMismatch {

0 commit comments

Comments
 (0)