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

DX12 textureLoad from a Stencil8 value in GREEN channel instead of RED #6620

Open
jbatez opened this issue Nov 26, 2024 · 0 comments
Open

DX12 textureLoad from a Stencil8 value in GREEN channel instead of RED #6620

jbatez opened this issue Nov 26, 2024 · 0 comments
Labels
api: dx12 Issues with DX12 or DXGI type: bug Something isn't working

Comments

@jbatez
Copy link

jbatez commented Nov 26, 2024

When I use WGSL textureLoad to read from a texture_2d<u32> bound to a Stencil8 texture view using the DX12 backend, the expected stencil value is in the GREEN channel. I expect it in the RED channel because of the WebGPU spec:

Reading or sampling the depth or stencil aspect of a texture behaves as if the texture contains the values (V, X, X, X), where V is the actual depth or stencil value, and each X is an implementation-defined unspecified value.

When I use the Vulkan backend instead, the value is in the RED channel as expected.

I assume this is because the actual SRV format the DX12 backend uses is DXGI_FORMAT_X24_TYPELESS_G8_UINT. I think you could use D3D12_SHADER_RESOURCE_VIEW_DESC::Shader4ComponentMapping to swizzle it into the RED channel.

@teoxoy teoxoy added type: bug Something isn't working api: dx12 Issues with DX12 or DXGI labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: dx12 Issues with DX12 or DXGI type: bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants