diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp index 2e2fb0f0b1..d03e4844f0 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp @@ -353,7 +353,7 @@ DXGI_FORMAT get_depth_stencil_surface_clear_format(u8 format) noexcept unreachable("Wrong depth stencil surface format"); } -DXGI_FORMAT get_depth_typeless_surface_format(u8 format) noexcept +DXGI_FORMAT get_depth_stencil_typeless_surface_format(u8 format) noexcept { switch (format) { @@ -363,6 +363,16 @@ DXGI_FORMAT get_depth_typeless_surface_format(u8 format) noexcept unreachable("Wrong depth stencil surface format"); } +DXGI_FORMAT get_depth_samplable_surface_format(u8 format) noexcept +{ + switch (format) + { + case CELL_GCM_SURFACE_Z16: return DXGI_FORMAT_R16_FLOAT; + case CELL_GCM_SURFACE_Z24S8: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; + } + unreachable("Wrong depth stencil surface format"); +} + BOOL get_front_face_ccw(u32 set_front_face_value) noexcept { switch (set_front_face_value) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h index 45fdac4114..df21fe501a 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h @@ -79,9 +79,14 @@ DXGI_FORMAT get_depth_stencil_surface_format(u8 format) noexcept; DXGI_FORMAT get_depth_stencil_surface_clear_format(u8 format) noexcept; /** - * Convert depth surface format to DXGI_FORMAT using typeless for stencil + * Convert depth surface format to a typeless DXGI_FORMAT */ -DXGI_FORMAT get_depth_typeless_surface_format(u8 format) noexcept; +DXGI_FORMAT get_depth_stencil_typeless_surface_format(u8 format) noexcept; + +/** +* Convert depth surface format to a DXGI_FORMAT that can be depth sampled +*/ +DXGI_FORMAT get_depth_samplable_surface_format(u8 format) noexcept; /** * Convert front face value to bool value telling wheter front face is counterclockwise or not diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index 7d6ad25d38..dc8a687b09 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -327,7 +327,7 @@ ID3D12Resource * render_targets::bind_address_as_depth_stencil(ID3D12Device * de D3D12_CLEAR_VALUE clear_depth_value = {}; clear_depth_value.DepthStencil.Depth = depthClear; - DXGI_FORMAT dxgi_format = get_depth_typeless_surface_format(surfaceDepthFormat); + DXGI_FORMAT dxgi_format = get_depth_stencil_typeless_surface_format(surfaceDepthFormat); clear_depth_value.Format = get_depth_stencil_surface_clear_format(surfaceDepthFormat); ComPtr new_depth_stencil; @@ -468,7 +468,7 @@ void D3D12GSRender::copy_render_target_to_dma_location() m_device->CreateDescriptorHeap(&descriptor_heap_desc, IID_PPV_ARGS(descriptor_heap.GetAddressOf())) ); D3D12_SHADER_RESOURCE_VIEW_DESC shader_resource_view_desc = {}; - m_surface.depth_format = get_depth_typeless_surface_format(m_surface.depth_format); + shader_resource_view_desc.Format = get_depth_samplable_surface_format(m_surface.depth_format); shader_resource_view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; shader_resource_view_desc.Texture2D.MipLevels = 1; shader_resource_view_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;