Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clamping when rendering onto R16Uint format textures #4670

Closed
mathiasplans opened this issue Nov 10, 2023 · 5 comments
Closed

Clamping when rendering onto R16Uint format textures #4670

mathiasplans opened this issue Nov 10, 2023 · 5 comments
Labels
api: vulkan Issues with Vulkan external: driver-bug A driver is causing the bug, though we may still want to work around it

Comments

@mathiasplans
Copy link

mathiasplans commented Nov 10, 2023

Hey. I was trying to render (headless) with R16Uint texture as the color attachment with the following fragment shader:

@fragment
fn fs_main(in: vertex_output) -> @location(0) u32 {
    return u32(in.color.r * 65535.0);
}

When I convert it into 16-bit PNG I get:
output

If I use this shader:

@fragment
fn fs_main(in: vertex_output) -> @location(0) u32 {
    return u32(in.color.r * 255.0);
}

I get the following PNG:
output

This PNG looks like what I expected from the first shader. However, it will not have full range of values (0 to 65535) so I can't use it. It looks like the output of the fragment shader is clamped to 255. Is this intentional?

The workaround I currently have is to use RG8Uint texture format and use this shader:

@fragment
fn fs_main(in: vertex_output) -> @location(0) vec2<u32> {
    var col1 = u32(in.color.r * 65535.0) >> 8u;
    var col2 = u32(in.color.r * 65535.0) & 255u;
    return vec2<u32>(col1, col2);
}
@rajveermalviya
Copy link
Contributor

cc @gfx-rs/wgpu (should probably be transferred to the wgpu repo)

@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/wgpu-native Nov 11, 2023
@teoxoy
Copy link
Member

teoxoy commented Nov 13, 2023

Which backend are you using? Also, what hardware/drivers do you have?

@mathiasplans
Copy link
Author

mathiasplans commented Nov 13, 2023

I am using Vulkan backend (dozen, so actually DirectX?) on WSLg. My PC has NVIDIA RTX A3000. Nvidia driver version is 529.08.

Now that I look at it with fresher eyes, I can't seem to find a reason why there would be black stripes there. If it were just clamping, there would be a solid white square.

@teoxoy
Copy link
Member

teoxoy commented Nov 13, 2023

Could you try to reproduce the issue in Windows (outside of WSL)? It might be an issue with Mesa's Dozen.

@teoxoy teoxoy added type: bug Something isn't working api: vulkan Issues with Vulkan external: driver-bug A driver is causing the bug, though we may still want to work around it and removed type: bug Something isn't working labels Nov 13, 2023
@teoxoy
Copy link
Member

teoxoy commented Nov 17, 2023

Dozen is not yet Vulkan conformant:

https://gitlab.freedesktop.org/mesa/mesa/-/blob/bafc27583cf7c2d136fa05764e5e2145fedbc9cc/src/microsoft/vulkan/dzn_device.c#L979-984

You should report this issue to the mesa repo.

@teoxoy teoxoy closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vulkan Issues with Vulkan external: driver-bug A driver is causing the bug, though we may still want to work around it
Projects
None yet
Development

No branches or pull requests

3 participants