[D3D12] ROV sample depth via ddxy(z), DSV depth bias cleanup
This commit is contained in:
@@ -3213,12 +3213,6 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
dirty |= system_constants_.edram_depth_base_dwords != depth_base_dwords;
|
||||
system_constants_.edram_depth_base_dwords = depth_base_dwords;
|
||||
|
||||
float depth_range_scale = viewport_info.z_max - viewport_info.z_min;
|
||||
dirty |= system_constants_.edram_depth_range_scale != depth_range_scale;
|
||||
system_constants_.edram_depth_range_scale = depth_range_scale;
|
||||
dirty |= system_constants_.edram_depth_range_offset != viewport_info.z_min;
|
||||
system_constants_.edram_depth_range_offset = viewport_info.z_min;
|
||||
|
||||
// For non-polygons, front polygon offset is used, and it's enabled if
|
||||
// POLY_OFFSET_PARA_ENABLED is set, for polygons, separate front and back
|
||||
// are used.
|
||||
@@ -3247,8 +3241,7 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
poly_offset_back_offset = poly_offset_front_offset;
|
||||
}
|
||||
}
|
||||
// "slope computed in subpixels (1/12 or 1/16)" - R5xx Acceleration. Also:
|
||||
// https://github.com/mesa3d/mesa/blob/54ad9b444c8e73da498211870e785239ad3ff1aa/src/gallium/drivers/radeonsi/si_state.c#L943
|
||||
// "slope computed in subpixels ([...] 1/16)" - R5xx Acceleration.
|
||||
poly_offset_front_scale *= (1.0f / 16.0f) * resolution_scale;
|
||||
poly_offset_back_scale *= (1.0f / 16.0f) * resolution_scale;
|
||||
dirty |= system_constants_.edram_poly_offset_front_scale !=
|
||||
|
||||
@@ -1457,31 +1457,16 @@ bool PipelineCache::GetCurrentStateDescription(
|
||||
}
|
||||
}
|
||||
if (!edram_rov_used) {
|
||||
// Conversion based on the calculations in Call of Duty 4 and the values it
|
||||
// writes to the registers, and also on:
|
||||
// https://github.com/mesa3d/mesa/blob/54ad9b444c8e73da498211870e785239ad3ff1aa/src/gallium/drivers/radeonsi/si_state.c#L943
|
||||
// Dividing the scale by 2 - Call of Duty 4 sets the constant bias of
|
||||
// 1/32768 for decals, however, it's done in two steps in separate places:
|
||||
// first it's divided by 65536, and then it's multiplied by 2 (which is
|
||||
// consistent with what si_create_rs_state does, which multiplies the offset
|
||||
// by 2 if it comes from a non-D3D9 API for 24-bit depth buffers) - and
|
||||
// multiplying by 2 to the number of significand bits. Tested mostly in Call
|
||||
// of Duty 4 (vehicledamage map explosion decals) and Red Dead Redemption
|
||||
// (shadows - 2^17 is not enough, 2^18 hasn't been tested, but 2^19
|
||||
// eliminates the acne).
|
||||
if (regs.Get<reg::RB_DEPTH_INFO>().depth_format ==
|
||||
xenos::DepthRenderTargetFormat::kD24FS8) {
|
||||
poly_offset *= float(1 << 19);
|
||||
} else {
|
||||
poly_offset *= float(1 << 23);
|
||||
}
|
||||
float poly_offset_host_scale = draw_util::GetD3D10PolygonOffsetScale(
|
||||
regs.Get<reg::RB_DEPTH_INFO>().depth_format, true);
|
||||
// Using ceil here just in case a game wants the offset but passes a value
|
||||
// that is too small - it's better to apply more offset than to make depth
|
||||
// fighting worse or to disable the offset completely (Direct3D 12 takes an
|
||||
// integer value).
|
||||
description_out.depth_bias = int32_t(std::ceil(std::abs(poly_offset))) *
|
||||
(poly_offset < 0.0f ? -1 : 1);
|
||||
// "slope computed in subpixels (1/12 or 1/16)" - R5xx Acceleration.
|
||||
description_out.depth_bias =
|
||||
int32_t(std::ceil(std::abs(poly_offset * poly_offset_host_scale))) *
|
||||
(poly_offset < 0.0f ? -1 : 1);
|
||||
// "slope computed in subpixels ([...] 1/16)" - R5xx Acceleration.
|
||||
description_out.depth_bias_slope_scaled =
|
||||
poly_offset_scale * (1.0f / 16.0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user