Commit 000ddca
authored
Support non-sRGB image formats for
# Objective
- Fixes #15201
## Solution
- It seems there was some confusion where
`OutputColorAttachment::format` could be different from the actual
underlying texture format (of `OutputColorAttachment::view`). This would
eventually lead to a texture format mismatch on the `BlitPipeline`. I
removed the `OutputColorAttachment::format` field to resolve this
conflict.
- Sim. for `ManualTextureView`.
## Testing
- The repro steps provided by #15201 no longer cause a WGPU validation
error.
- I tested the `pbr` example on native and WebGPU and it still works as
before.
## Future Work
Although the WGPU validation error is fixed, when using a non-sRGB
texture format for the GPU image in the `headless_renderer` example, the
output image seems to have incorrect gamma. I think this is because the
example does a byte-for-byte copy from the GPU image to the CPU image
without any gamma correction; and the `image` crate saves the image
assuming a nonlinear color space.
I don't think we need to fix this as part of this PR, but it might be
nice for `bevy_image::Image::try_into_dynamic` to eventually handle the
gamma correction when saving linear color images.
<details>
<summary>Here you can see a comparison</summary>
With sRGB
<img width="1920" height="1080" alt="with_srgb"
src="https://github.com/user-attachments/assets/b6d96072-2754-4fc3-bb5a-fc2994e65dc0"
/>
No sRGB
<img width="1920" height="1080" alt="no_srgb"
src="https://github.com/user-attachments/assets/46f83f85-2202-40f6-9a68-85bdf4631494"
/>
</details>RenderTarget::Image (#22031)1 parent f860ee7 commit 000ddca
File tree
5 files changed
+16
-32
lines changed- crates/bevy_render/src
- texture
- view
- window
5 files changed
+16
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
217 | | - | |
218 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
| |||
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | | - | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 17 | + | |
| 18 | + | |
26 | 19 | | |
27 | 20 | | |
28 | 21 | | |
| |||
36 | 29 | | |
37 | 30 | | |
38 | 31 | | |
39 | | - | |
| 32 | + | |
40 | 33 | | |
41 | 34 | | |
42 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | 130 | | |
132 | 131 | | |
133 | 132 | | |
134 | 133 | | |
135 | | - | |
| 134 | + | |
136 | 135 | | |
137 | 136 | | |
138 | | - | |
139 | 137 | | |
140 | 138 | | |
141 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
838 | 838 | | |
839 | 839 | | |
840 | 840 | | |
841 | | - | |
| 841 | + | |
842 | 842 | | |
843 | 843 | | |
844 | 844 | | |
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
| 1017 | + | |
1021 | 1018 | | |
1022 | 1019 | | |
1023 | 1020 | | |
| |||
1086 | 1083 | | |
1087 | 1084 | | |
1088 | 1085 | | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
| 1086 | + | |
1094 | 1087 | | |
1095 | 1088 | | |
1096 | 1089 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | | - | |
| 318 | + | |
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
553 | | - | |
| 553 | + | |
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| |||
0 commit comments