|
1027 | 1027 | <a href="#1026" id="1026">1026</a> |
1028 | 1028 | <a href="#1027" id="1027">1027</a> |
1029 | 1029 | <a href="#1028" id="1028">1028</a> |
1030 | | -<a href="#1029" id="1029">1029</a></pre></div><pre class="rust"><code><span class="kw">use crate</span>::{ |
| 1030 | +<a href="#1029" id="1029">1029</a> |
| 1031 | +<a href="#1030" id="1030">1030</a> |
| 1032 | +<a href="#1031" id="1031">1031</a> |
| 1033 | +<a href="#1032" id="1032">1032</a> |
| 1034 | +<a href="#1033" id="1033">1033</a> |
| 1035 | +<a href="#1034" id="1034">1034</a> |
| 1036 | +<a href="#1035" id="1035">1035</a> |
| 1037 | +<a href="#1036" id="1036">1036</a> |
| 1038 | +<a href="#1037" id="1037">1037</a> |
| 1039 | +<a href="#1038" id="1038">1038</a> |
| 1040 | +<a href="#1039" id="1039">1039</a> |
| 1041 | +<a href="#1040" id="1040">1040</a> |
| 1042 | +<a href="#1041" id="1041">1041</a> |
| 1043 | +<a href="#1042" id="1042">1042</a> |
| 1044 | +<a href="#1043" id="1043">1043</a> |
| 1045 | +<a href="#1044" id="1044">1044</a> |
| 1046 | +<a href="#1045" id="1045">1045</a> |
| 1047 | +<a href="#1046" id="1046">1046</a> |
| 1048 | +<a href="#1047" id="1047">1047</a> |
| 1049 | +<a href="#1048" id="1048">1048</a> |
| 1050 | +<a href="#1049" id="1049">1049</a> |
| 1051 | +<a href="#1050" id="1050">1050</a> |
| 1052 | +<a href="#1051" id="1051">1051</a> |
| 1053 | +<a href="#1052" id="1052">1052</a> |
| 1054 | +<a href="#1053" id="1053">1053</a> |
| 1055 | +<a href="#1054" id="1054">1054</a></pre></div><pre class="rust"><code><span class="kw">use crate</span>::{ |
1031 | 1056 | device::{ |
1032 | 1057 | bgl, Device, DeviceError, MissingDownlevelFlags, MissingFeatures, SHADER_STAGE_COUNT, |
1033 | 1058 | }, |
|
1097 | 1122 | }, |
1098 | 1123 | <span class="attr">#[error(transparent)] |
1099 | 1124 | </span>TooManyBindings(BindingTypeMaxCountError), |
| 1125 | + <span class="attr">#[error(<span class="string">"Bind groups may not contain both a binding array and a dynamically offset buffer"</span>)] |
| 1126 | + </span>ContainsBothBindingArrayAndDynamicOffsetArray, |
| 1127 | + <span class="attr">#[error(<span class="string">"Bind groups may not contain both a binding array and a uniform buffer"</span>)] |
| 1128 | + </span>ContainsBothBindingArrayAndUniformBuffer, |
1100 | 1129 | <span class="attr">#[error(<span class="string">"Binding index {binding} is greater than the maximum number {maximum}"</span>)] |
1101 | 1130 | </span>InvalidBindingIndex { binding: u32, maximum: u32 }, |
1102 | 1131 | <span class="attr">#[error(<span class="string">"Invalid visibility {0:?}"</span>)] |
|
1348 | 1377 | storage_textures: PerStageBindingTypeCounter, |
1349 | 1378 | uniform_buffers: PerStageBindingTypeCounter, |
1350 | 1379 | acceleration_structures: PerStageBindingTypeCounter, |
| 1380 | + has_bindless_array: bool, |
1351 | 1381 | } |
1352 | 1382 |
|
1353 | 1383 | <span class="kw">impl </span>BindingTypeMaxCountValidator { |
|
1387 | 1417 | <span class="self">self</span>.acceleration_structures.add(binding.visibility, count); |
1388 | 1418 | } |
1389 | 1419 | } |
| 1420 | + <span class="kw">if </span>binding.count.is_some() { |
| 1421 | + <span class="self">self</span>.has_bindless_array = <span class="bool-val">true</span>; |
| 1422 | + } |
1390 | 1423 | } |
1391 | 1424 |
|
1392 | 1425 | <span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>merge(<span class="kw-2">&mut </span><span class="self">self</span>, other: <span class="kw-2">&</span><span class="self">Self</span>) { |
|
1438 | 1471 | )<span class="question-mark">?</span>; |
1439 | 1472 | <span class="prelude-val">Ok</span>(()) |
1440 | 1473 | } |
| 1474 | + |
| 1475 | + <span class="doccomment">/// Validate that the bind group layout does not contain both a binding array and a dynamic offset array. |
| 1476 | + /// |
| 1477 | + /// This allows us to use `UPDATE_AFTER_BIND` on vulkan for bindless arrays. Vulkan does not allow |
| 1478 | + /// `UPDATE_AFTER_BIND` on dynamic offset arrays. See <https://github.com/gfx-rs/wgpu/issues/6737> |
| 1479 | + </span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>validate_binding_arrays(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="prelude-ty">Result</span><(), CreateBindGroupLayoutError> { |
| 1480 | + <span class="kw">let </span>has_dynamic_offset_array = |
| 1481 | + <span class="self">self</span>.dynamic_uniform_buffers > <span class="number">0 </span>|| <span class="self">self</span>.dynamic_storage_buffers > <span class="number">0</span>; |
| 1482 | + <span class="kw">let </span>has_uniform_buffer = <span class="self">self</span>.uniform_buffers.max().<span class="number">1 </span>> <span class="number">0</span>; |
| 1483 | + <span class="kw">if </span><span class="self">self</span>.has_bindless_array && has_dynamic_offset_array { |
| 1484 | + <span class="kw">return </span><span class="prelude-val">Err</span>(CreateBindGroupLayoutError::ContainsBothBindingArrayAndDynamicOffsetArray); |
| 1485 | + } |
| 1486 | + <span class="kw">if </span><span class="self">self</span>.has_bindless_array && has_uniform_buffer { |
| 1487 | + <span class="kw">return </span><span class="prelude-val">Err</span>(CreateBindGroupLayoutError::ContainsBothBindingArrayAndUniformBuffer); |
| 1488 | + } |
| 1489 | + <span class="prelude-val">Ok</span>(()) |
| 1490 | + } |
1441 | 1491 | } |
1442 | 1492 |
|
1443 | 1493 | <span class="doccomment">/// Bindable resource and the slot to bind it to. |
|
0 commit comments