Stencil8 support fixups
Addressing issues that showed up after the initial stencil8 CL landed. D3D12: - Selecting the `all` aspect of a `stencil8` texture was ASSERTing Metal: - Using the `stencil` aspect of a `stencil8` texture was hitting an UNREACHABLE(). Bug: dawn:666 Change-Id: Ic2931dbb915e109727ca24e3216a661fba84e508 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85021 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
parent
431926670f
commit
bf0f2c1849
|
@ -1184,7 +1184,21 @@ namespace dawn::native::d3d12 {
|
||||||
case wgpu::TextureFormat::Depth16Unorm:
|
case wgpu::TextureFormat::Depth16Unorm:
|
||||||
mSrvDesc.Format = DXGI_FORMAT_R16_UNORM;
|
mSrvDesc.Format = DXGI_FORMAT_R16_UNORM;
|
||||||
break;
|
break;
|
||||||
case wgpu::TextureFormat::Stencil8:
|
case wgpu::TextureFormat::Stencil8: {
|
||||||
|
// Stencil8 is always backed by a DXGI_FORMAT_R24G8_TYPELESS texture in D3D12,
|
||||||
|
// so always treat it as if the StencilOnly aspect of a Depth24UnormStencil8 was
|
||||||
|
// selected.
|
||||||
|
planeSlice = 1;
|
||||||
|
mSrvDesc.Format = DXGI_FORMAT_X24_TYPELESS_G8_UINT;
|
||||||
|
// Stencil is accessed using the .g component in the shader.
|
||||||
|
// Map it to the zeroth component to match other APIs.
|
||||||
|
mSrvDesc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(
|
||||||
|
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||||
|
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0,
|
||||||
|
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0,
|
||||||
|
D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case wgpu::TextureFormat::Depth24UnormStencil8:
|
case wgpu::TextureFormat::Depth24UnormStencil8:
|
||||||
switch (descriptor->aspect) {
|
switch (descriptor->aspect) {
|
||||||
case wgpu::TextureAspect::DepthOnly:
|
case wgpu::TextureAspect::DepthOnly:
|
||||||
|
|
|
@ -1060,7 +1060,8 @@ namespace dawn::native::metal {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MTLPixelFormat format = MetalPixelFormat(descriptor->format);
|
MTLPixelFormat format = MetalPixelFormat(descriptor->format);
|
||||||
if (descriptor->aspect == wgpu::TextureAspect::StencilOnly) {
|
if (descriptor->aspect == wgpu::TextureAspect::StencilOnly &&
|
||||||
|
format != MTLPixelFormatStencil8) {
|
||||||
if (@available(macOS 10.12, iOS 10.0, *)) {
|
if (@available(macOS 10.12, iOS 10.0, *)) {
|
||||||
if (format == MTLPixelFormatDepth32Float_Stencil8) {
|
if (format == MTLPixelFormatDepth32Float_Stencil8) {
|
||||||
format = MTLPixelFormatX32_Stencil8;
|
format = MTLPixelFormatX32_Stencil8;
|
||||||
|
|
Loading…
Reference in New Issue