Commit 3cf98a6
authored
Make BUFFER_BINDING_ARRAY conditional on whether the material uses
buffer binding arrays. Fix sampler limit to check array element count
instead of binding slot count. Only create binding arrays for resource
types the material actually uses, reducing overhead on all platforms.
## Objective
Fixes #18149
Metal supports `TEXTURE_BINDING_ARRAY` but not `BUFFER_BINDING_ARRAY`.
Bindless was disabled entirely on Metal because `bindless_supported()`
required both unconditionally.
## Solution
1. **Conditional feature check**: Only require `BUFFER_BINDING_ARRAY`
when the material actually uses buffer binding arrays.
2. Materials using `#[data(...)]`, textures, and samplers (like
`StandardMaterial`) only need `TEXTURE_BINDING_ARRAY`. **Fix sampler
limit check**: Use `max_binding_array_sampler_elements_per_shader_stage`
(array element count) instead of `max_samplers_per_shader_stage`
(binding slot count).
3. **Only create needed binding arrays**:
`create_bindless_bind_group_layout_entries` now skips resource types the
material doesn't use. This stays within Metal's 31 argument buffer slot
limit and reduces wasted fallback resources on all platforms.
## Testing
Bistro Exterior (698 materials), 5-minute runs:
| GPU | Avg FPS (before → after) | Min FPS (before → after) | RAM/VRAM |
|-----|--------------------------|--------------------------|----------|
| Apple M2 Max (Metal) | 115 → 136 **(+18%)** | 60 → 106 **(+77%)** |
-57 MB RAM |
| NVIDIA 5060 Ti | 118 → 217 **(+84%)** | 60 → 165 **(+174%)** | Same |
| Intel i360P | 25 → 29 **(+15%)** | Same | Same |
| AMD Vega 8 / Ryzen 4800U | 25 → 25 | Same | **-88 MB VRAM** |
| Intel Iris XE | ~22 → ~22 | Same | No regression |
Also tested: `3d_scene`, `pbr`, `lighting`, `transmission`,
`deferred_rendering`: all pass with zero errors.
Materials using `#[uniform(..., binding_array(...))]` correctly fall
back to non-bindless on Metal.
1 parent 862ba07 commit 3cf98a6
4 files changed
Lines changed: 136 additions & 72 deletions
File tree
- _release-content/release-notes
- crates
- bevy_pbr/src
- bevy_render
- macros/src
- src/render_resource
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1355 | 1355 | | |
1356 | 1356 | | |
1357 | 1357 | | |
| 1358 | + | |
1358 | 1359 | | |
1359 | 1360 | | |
1360 | 1361 | | |
1361 | 1362 | | |
1362 | 1363 | | |
1363 | 1364 | | |
1364 | 1365 | | |
| 1366 | + | |
1365 | 1367 | | |
1366 | 1368 | | |
1367 | 1369 | | |
| |||
1382 | 1384 | | |
1383 | 1385 | | |
1384 | 1386 | | |
| 1387 | + | |
1385 | 1388 | | |
1386 | 1389 | | |
1387 | 1390 | | |
| |||
1399 | 1402 | | |
1400 | 1403 | | |
1401 | 1404 | | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
1402 | 1413 | | |
1403 | 1414 | | |
1404 | 1415 | | |
| |||
1443 | 1454 | | |
1444 | 1455 | | |
1445 | 1456 | | |
| 1457 | + | |
1446 | 1458 | | |
1447 | 1459 | | |
1448 | 1460 | | |
| |||
1459 | 1471 | | |
1460 | 1472 | | |
1461 | 1473 | | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
1462 | 1482 | | |
1463 | 1483 | | |
1464 | 1484 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
| |||
225 | 231 | | |
226 | 232 | | |
227 | 233 | | |
| 234 | + | |
228 | 235 | | |
229 | 236 | | |
230 | 237 | | |
| |||
501 | 508 | | |
502 | 509 | | |
503 | 510 | | |
| 511 | + | |
| 512 | + | |
504 | 513 | | |
505 | 514 | | |
506 | 515 | | |
| |||
953 | 962 | | |
954 | 963 | | |
955 | 964 | | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
956 | 979 | | |
957 | 980 | | |
958 | 981 | | |
959 | 982 | | |
960 | 983 | | |
961 | | - | |
962 | | - | |
| 984 | + | |
963 | 985 | | |
964 | 986 | | |
965 | | - | |
| 987 | + | |
966 | 988 | | |
967 | 989 | | |
968 | 990 | | |
| |||
1090 | 1112 | | |
1091 | 1113 | | |
1092 | 1114 | | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
1093 | 1118 | | |
1094 | 1119 | | |
1095 | 1120 | | |
1096 | 1121 | | |
1097 | 1122 | | |
1098 | 1123 | | |
| 1124 | + | |
1099 | 1125 | | |
1100 | 1126 | | |
1101 | 1127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 223 | + | |
| 224 | + | |
226 | 225 | | |
227 | 226 | | |
228 | 227 | | |
229 | 228 | | |
| 229 | + | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 234 | + | |
238 | 235 | | |
239 | | - | |
240 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
305 | 300 | | |
306 | 301 | | |
307 | 302 | | |
| |||
0 commit comments