[GPU] Ignore z_enable for !z_write_enable && z_func == ALWAYS
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "xenia/gpu/d3d12/d3d12_shader.h"
|
||||
#include "xenia/gpu/draw_util.h"
|
||||
#include "xenia/gpu/gpu_flags.h"
|
||||
#include "xenia/gpu/registers.h"
|
||||
#include "xenia/gpu/xenos.h"
|
||||
#include "xenia/ui/d3d12/d3d12_presenter.h"
|
||||
#include "xenia/ui/d3d12/d3d12_util.h"
|
||||
@@ -2127,14 +2128,17 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
return true;
|
||||
}
|
||||
|
||||
reg::RB_DEPTHCONTROL normalized_depth_control =
|
||||
draw_util::GetNormalizedDepthControl(regs);
|
||||
|
||||
// Shader modifications.
|
||||
DxbcShaderTranslator::Modification vertex_shader_modification =
|
||||
pipeline_cache_->GetCurrentVertexShaderModification(
|
||||
*vertex_shader, primitive_processing_result.host_vertex_shader_type);
|
||||
DxbcShaderTranslator::Modification pixel_shader_modification =
|
||||
pixel_shader
|
||||
? pipeline_cache_->GetCurrentPixelShaderModification(*pixel_shader)
|
||||
: DxbcShaderTranslator::Modification(0);
|
||||
pixel_shader ? pipeline_cache_->GetCurrentPixelShaderModification(
|
||||
*pixel_shader, normalized_depth_control)
|
||||
: DxbcShaderTranslator::Modification(0);
|
||||
|
||||
// Set up the render targets - this may perform dispatches and draws.
|
||||
uint32_t normalized_color_mask =
|
||||
@@ -2142,6 +2146,7 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
regs, pixel_shader->writes_color_targets())
|
||||
: 0;
|
||||
if (!render_target_cache_->Update(is_rasterization_done,
|
||||
normalized_depth_control,
|
||||
normalized_color_mask)) {
|
||||
return false;
|
||||
}
|
||||
@@ -2173,8 +2178,8 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
ID3D12RootSignature* root_signature;
|
||||
if (!pipeline_cache_->ConfigurePipeline(
|
||||
vertex_shader_translation, pixel_shader_translation,
|
||||
primitive_processing_result, normalized_color_mask,
|
||||
bound_depth_and_color_render_target_bits,
|
||||
primitive_processing_result, normalized_depth_control,
|
||||
normalized_color_mask, bound_depth_and_color_render_target_bits,
|
||||
bound_depth_and_color_render_target_formats, &pipeline_handle,
|
||||
&root_signature)) {
|
||||
return false;
|
||||
@@ -2206,6 +2211,7 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
draw_util::GetHostViewportInfo(
|
||||
regs, resolution_scale_x, resolution_scale_y, true,
|
||||
D3D12_VIEWPORT_BOUNDS_MAX, D3D12_VIEWPORT_BOUNDS_MAX, false,
|
||||
normalized_depth_control,
|
||||
host_render_targets_used &&
|
||||
(depth_float24_conversion ==
|
||||
RenderTargetCache::DepthFloat24Conversion::kOnOutputTruncating ||
|
||||
@@ -2221,7 +2227,8 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
scissor.extent[1] *= resolution_scale_y;
|
||||
|
||||
// Update viewport, scissor, blend factor and stencil reference.
|
||||
UpdateFixedFunctionState(viewport_info, scissor, primitive_polygonal);
|
||||
UpdateFixedFunctionState(viewport_info, scissor, primitive_polygonal,
|
||||
normalized_depth_control);
|
||||
|
||||
// Update system constants before uploading them.
|
||||
// TODO(Triang3l): With ROV, pass the disabled render target mask for safety.
|
||||
@@ -2229,7 +2236,7 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
memexport_used, primitive_polygonal,
|
||||
primitive_processing_result.line_loop_closing_index,
|
||||
primitive_processing_result.host_index_endian, viewport_info,
|
||||
used_texture_mask, normalized_color_mask);
|
||||
used_texture_mask, normalized_depth_control, normalized_color_mask);
|
||||
|
||||
// Update constant buffers, descriptors and root parameters.
|
||||
if (!UpdateBindings(vertex_shader, pixel_shader, root_signature)) {
|
||||
@@ -3029,7 +3036,8 @@ void D3D12CommandProcessor::ClearCommandAllocatorCache() {
|
||||
|
||||
void D3D12CommandProcessor::UpdateFixedFunctionState(
|
||||
const draw_util::ViewportInfo& viewport_info,
|
||||
const draw_util::Scissor& scissor, bool primitive_polygonal) {
|
||||
const draw_util::Scissor& scissor, bool primitive_polygonal,
|
||||
reg::RB_DEPTHCONTROL normalized_depth_control) {
|
||||
#if XE_UI_D3D12_FINE_GRAINED_DRAW_SCOPES
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
#endif // XE_UI_D3D12_FINE_GRAINED_DRAW_SCOPES
|
||||
@@ -3077,8 +3085,7 @@ void D3D12CommandProcessor::UpdateFixedFunctionState(
|
||||
// choose the back face one only if drawing only back faces.
|
||||
Register stencil_ref_mask_reg;
|
||||
auto pa_su_sc_mode_cntl = regs.Get<reg::PA_SU_SC_MODE_CNTL>();
|
||||
if (primitive_polygonal &&
|
||||
draw_util::GetDepthControlForCurrentEdramMode(regs).backface_enable &&
|
||||
if (primitive_polygonal && normalized_depth_control.backface_enable &&
|
||||
pa_su_sc_mode_cntl.cull_front && !pa_su_sc_mode_cntl.cull_back) {
|
||||
stencil_ref_mask_reg = XE_GPU_REG_RB_STENCILREFMASK_BF;
|
||||
} else {
|
||||
@@ -3099,6 +3106,7 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
bool shared_memory_is_uav, bool primitive_polygonal,
|
||||
uint32_t line_loop_closing_index, xenos::Endian index_endian,
|
||||
const draw_util::ViewportInfo& viewport_info, uint32_t used_texture_mask,
|
||||
reg::RB_DEPTHCONTROL normalized_depth_control,
|
||||
uint32_t normalized_color_mask) {
|
||||
#if XE_UI_D3D12_FINE_GRAINED_DRAW_SCOPES
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
@@ -3113,7 +3121,6 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
float rb_alpha_ref = regs[XE_GPU_REG_RB_ALPHA_REF].f32;
|
||||
auto rb_colorcontrol = regs.Get<reg::RB_COLORCONTROL>();
|
||||
auto rb_depth_info = regs.Get<reg::RB_DEPTH_INFO>();
|
||||
auto rb_depthcontrol = draw_util::GetDepthControlForCurrentEdramMode(regs);
|
||||
auto rb_stencilrefmask = regs.Get<reg::RB_STENCILREFMASK>();
|
||||
auto rb_stencilrefmask_bf =
|
||||
regs.Get<reg::RB_STENCILREFMASK>(XE_GPU_REG_RB_STENCILREFMASK_BF);
|
||||
@@ -3155,8 +3162,8 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
// Disable depth and stencil if it aliases a color render target (for
|
||||
// instance, during the XBLA logo in 58410954, though depth writing is already
|
||||
// disabled there).
|
||||
bool depth_stencil_enabled =
|
||||
rb_depthcontrol.stencil_enable || rb_depthcontrol.z_enable;
|
||||
bool depth_stencil_enabled = normalized_depth_control.stencil_enable ||
|
||||
normalized_depth_control.z_enable;
|
||||
if (edram_rov_used && depth_stencil_enabled) {
|
||||
for (uint32_t i = 0; i < 4; ++i) {
|
||||
if (rb_depth_info.depth_base == color_infos[i].color_base &&
|
||||
@@ -3229,10 +3236,10 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
}
|
||||
if (edram_rov_used && depth_stencil_enabled) {
|
||||
flags |= DxbcShaderTranslator::kSysFlag_ROVDepthStencil;
|
||||
if (rb_depthcontrol.z_enable) {
|
||||
flags |= uint32_t(rb_depthcontrol.zfunc)
|
||||
if (normalized_depth_control.z_enable) {
|
||||
flags |= uint32_t(normalized_depth_control.zfunc)
|
||||
<< DxbcShaderTranslator::kSysFlag_ROVDepthPassIfLess_Shift;
|
||||
if (rb_depthcontrol.z_write_enable) {
|
||||
if (normalized_depth_control.z_write_enable) {
|
||||
flags |= DxbcShaderTranslator::kSysFlag_ROVDepthWrite;
|
||||
}
|
||||
} else {
|
||||
@@ -3242,7 +3249,7 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
DxbcShaderTranslator::kSysFlag_ROVDepthPassIfEqual |
|
||||
DxbcShaderTranslator::kSysFlag_ROVDepthPassIfGreater;
|
||||
}
|
||||
if (rb_depthcontrol.stencil_enable) {
|
||||
if (normalized_depth_control.stencil_enable) {
|
||||
flags |= DxbcShaderTranslator::kSysFlag_ROVStencilTest;
|
||||
}
|
||||
// Hint - if not applicable to the shader, will not have effect.
|
||||
@@ -3526,7 +3533,7 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
poly_offset_back_offset;
|
||||
system_constants_.edram_poly_offset_back_offset = poly_offset_back_offset;
|
||||
|
||||
if (depth_stencil_enabled && rb_depthcontrol.stencil_enable) {
|
||||
if (depth_stencil_enabled && normalized_depth_control.stencil_enable) {
|
||||
dirty |= system_constants_.edram_stencil_front_reference !=
|
||||
rb_stencilrefmask.stencilref;
|
||||
system_constants_.edram_stencil_front_reference =
|
||||
@@ -3540,12 +3547,12 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
system_constants_.edram_stencil_front_write_mask =
|
||||
rb_stencilrefmask.stencilwritemask;
|
||||
uint32_t stencil_func_ops =
|
||||
(rb_depthcontrol.value >> 8) & ((1 << 12) - 1);
|
||||
(normalized_depth_control.value >> 8) & ((1 << 12) - 1);
|
||||
dirty |=
|
||||
system_constants_.edram_stencil_front_func_ops != stencil_func_ops;
|
||||
system_constants_.edram_stencil_front_func_ops = stencil_func_ops;
|
||||
|
||||
if (primitive_polygonal && rb_depthcontrol.backface_enable) {
|
||||
if (primitive_polygonal && normalized_depth_control.backface_enable) {
|
||||
dirty |= system_constants_.edram_stencil_back_reference !=
|
||||
rb_stencilrefmask_bf.stencilref;
|
||||
system_constants_.edram_stencil_back_reference =
|
||||
@@ -3559,7 +3566,7 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
system_constants_.edram_stencil_back_write_mask =
|
||||
rb_stencilrefmask_bf.stencilwritemask;
|
||||
uint32_t stencil_func_ops_bf =
|
||||
(rb_depthcontrol.value >> 20) & ((1 << 12) - 1);
|
||||
(normalized_depth_control.value >> 20) & ((1 << 12) - 1);
|
||||
dirty |= system_constants_.edram_stencil_back_func_ops !=
|
||||
stencil_func_ops_bf;
|
||||
system_constants_.edram_stencil_back_func_ops = stencil_func_ops_bf;
|
||||
|
||||
Reference in New Issue
Block a user