Commit 4494ab1
authored
Implement view_formats in create_texture (#832)
`create_texture()` accepted a `view_formats` argument and then raised
NotImplementedError for any non-empty value, while the descriptor it
fills already carried `viewFormatCount` / `viewFormats`, commented out as
unused. This wires them up using the same conversion the surface
configuration path in this file already performs.
WebGPU allows a texture view to reinterpret the texture as any format
listed in `viewFormats` at creation, and only those. The common use is
the srgb/non-srgb pair: sampling an srgb texture applies the transfer
function, so reading back the bytes that were actually written requires
a view in the plain format. Without `view_formats` there is no way to ask
for that view, and the only workaround is to copy the whole texture into
a second one of the plain format -- a full-frame copy, every frame, plus
the memory for the duplicate.
Adds a test covering a declared view format, the texture's own format, an
undeclared format still being rejected, and a texture that declares none
keeping the previous behaviour.1 parent 2c6ce9a commit 4494ab1
2 files changed
Lines changed: 39 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
327 | 359 | | |
328 | 360 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1498 | 1498 | | |
1499 | 1499 | | |
1500 | 1500 | | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
1505 | 1506 | | |
1506 | 1507 | | |
1507 | 1508 | | |
| |||
1522 | 1523 | | |
1523 | 1524 | | |
1524 | 1525 | | |
1525 | | - | |
1526 | | - | |
| 1526 | + | |
| 1527 | + | |
1527 | 1528 | | |
1528 | 1529 | | |
1529 | 1530 | | |
| |||
0 commit comments