Conversation
|
Welcome! We discussed this in the #office hours > Renderer 2026-07-29 meeting, and think that this kind of note is valuable. However, I think that the exact way that this is expressed is a little bit unclear - do you have a code example for what your proposed fix is? Fwiw, in |
|
Yes, using a non-Srgb surface texture format also works, and should be mentioned. In my application, I'm using Vello to draw UI that is blitted on top of other renders, so I want the Vello pipeline to be able to handle any surface texture format. My application code looks something like this: const VELLO_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;
impl VelloPipeline {
/// `target_format` is the texture format of the view passed to `draw_ui`
fn new(device: &wgpu::Device, target_format: wgpu::TextureFormat) -> Self {
let vello_texture: wgpu::Texture = device.create_texture(&wgpu::TextureDescriptor {
format: VELLO_FORMAT,
// ...
});
let vello_texture_view = vello_texture.create_view(&wgpu::TextureViewDescriptor {
format: target_format.is_srgb().then(|| VELLO_FORMAT.add_srgb_suffix()),
usage: Some(wgpu::TextureUsages::TEXTURE_BINDING),
});
}
fn draw_ui(&self, encoder: &mut wgpu::CommandEncoder, target: &wgpu::TextureView) {
// blit `vello_texture_view` to `target`, perhaps through wgpu::util::TextureBlitter
}When I create the surface view texture in my windowing code, I use the first format returned in There are some wgpu docs on this topic but they're lower-level than is probably helpful for this method. The |
|
I suspect that just pointing to the that wgpu doc is probably the best approach. I don't really have the context in my head to even review anything else! You might also be able to find someone else who could review this, but I'm not sure who the candidates would be currently... |
This PR adds a helpful note to
Renderer::render_to_textureabout sRGB conversions to avoid washed out colors when rendering. I found this behavior surprising, and had to go down a big rabbit hole about color spaces to understand it.