Commit a4cfc24
authored
make material draw functions instance independent (#21021)
# Objective
#19667 introduced a type-erased material system that effectively puts
all material instances through a single cache: during asset preparation
(`ErasedRenderAssetPlugin`), materials are processed into a set of
`MaterialProperties` that contains all the data needed to render them,
and these are all cached and deduplicated as needed.
This allows for maximal flexibility (every single material instance
could have a different ""type"") but complicates the logic and makes
cache keys really big. So, one goal for the material revamp I have (and
I think @tychedelia is on board) is to cache materials at two levels:
material "types" and material "instances", where material types roughly
map to the rust types that currently implement `Material`. Without
getting into implementation details, storing mostly static data separate
from instance data would let us simplify a lot of the logic, while only
requiring a little more work for fully-dynamic use cases.
This PR is a first step in that direction, which stores *all* the
available draw functions in `MaterialProperties`, and pushes the
decision for "what draw function should I use for this material?" to
queue time, where before it was split between there and asset
preparation. This makes the list of available draw functions
instance-independent, and will later allow us to store it with other
"static" material data.
## Solution
- Make draw function labels 1:1 with render phases, and include all of
them in the list in `MaterialProperties`
## Testing
- Ran `3d_scene`
- Ran `manual_material`1 parent ffd0121 commit a4cfc24
File tree
4 files changed
+128
-70
lines changed- crates/bevy_pbr/src
- prepass
- examples/shader_advanced
- release-content/migration-guides
4 files changed
+128
-70
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1214 | 1214 | | |
1215 | 1215 | | |
1216 | 1216 | | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | 1217 | | |
1222 | 1218 | | |
1223 | 1219 | | |
1224 | 1220 | | |
1225 | 1221 | | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
1226 | 1228 | | |
1227 | 1229 | | |
1228 | 1230 | | |
| |||
1242 | 1244 | | |
1243 | 1245 | | |
1244 | 1246 | | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
1245 | 1253 | | |
1246 | 1254 | | |
1247 | 1255 | | |
| |||
1267 | 1275 | | |
1268 | 1276 | | |
1269 | 1277 | | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
1270 | 1284 | | |
1271 | 1285 | | |
1272 | 1286 | | |
| |||
1292 | 1306 | | |
1293 | 1307 | | |
1294 | 1308 | | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
1295 | 1315 | | |
1296 | 1316 | | |
1297 | 1317 | | |
| |||
1385 | 1405 | | |
1386 | 1406 | | |
1387 | 1407 | | |
1388 | | - | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
1389 | 1415 | | |
1390 | 1416 | | |
1391 | | - | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
1392 | 1420 | | |
1393 | 1421 | | |
1394 | | - | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
1395 | 1425 | | |
1396 | 1426 | | |
1397 | 1427 | | |
| |||
1633 | 1663 | | |
1634 | 1664 | | |
1635 | 1665 | | |
1636 | | - | |
1637 | | - | |
1638 | | - | |
1639 | | - | |
1640 | | - | |
1641 | | - | |
1642 | | - | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
1643 | 1669 | | |
1644 | 1670 | | |
1645 | | - | |
1646 | | - | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
1647 | 1697 | | |
1648 | 1698 | | |
1649 | 1699 | | |
| |||
1669 | 1719 | | |
1670 | 1720 | | |
1671 | 1721 | | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
1675 | | - | |
1676 | | - | |
1677 | | - | |
1678 | | - | |
1679 | | - | |
1680 | | - | |
1681 | | - | |
1682 | | - | |
1683 | | - | |
1684 | | - | |
1685 | | - | |
1686 | | - | |
1687 | | - | |
1688 | | - | |
1689 | | - | |
1690 | | - | |
1691 | | - | |
1692 | | - | |
1693 | | - | |
1694 | | - | |
1695 | | - | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
1699 | | - | |
1700 | | - | |
1701 | 1722 | | |
1702 | 1723 | | |
1703 | 1724 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
1087 | 1088 | | |
1088 | 1089 | | |
1089 | 1090 | | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1090 | 1097 | | |
1091 | 1098 | | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
| 1099 | + | |
1096 | 1100 | | |
1097 | 1101 | | |
1098 | 1102 | | |
| |||
1112 | 1116 | | |
1113 | 1117 | | |
1114 | 1118 | | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
1115 | 1125 | | |
1116 | 1126 | | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
| 1127 | + | |
1121 | 1128 | | |
1122 | 1129 | | |
1123 | 1130 | | |
| |||
1140 | 1147 | | |
1141 | 1148 | | |
1142 | 1149 | | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
1143 | 1156 | | |
1144 | | - | |
1145 | | - | |
1146 | | - | |
1147 | | - | |
| 1157 | + | |
1148 | 1158 | | |
1149 | 1159 | | |
1150 | 1160 | | |
| |||
1167 | 1177 | | |
1168 | 1178 | | |
1169 | 1179 | | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1170 | 1186 | | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
| 1187 | + | |
1175 | 1188 | | |
1176 | 1189 | | |
1177 | 1190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
| 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 | + | |
| 24 | + | |
0 commit comments