Skip to content

Commit c280498

Browse files
GS/DX11/GL: Further cleanup to the copy behavior and some features checks.
1 parent aa9b04e commit c280498

2 files changed

Lines changed: 33 additions & 15 deletions

File tree

pcsx2/GS/Renderers/DX11/GSDevice11.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ GSDevice11::GSDevice11()
5757

5858
m_features.primitive_id = true;
5959
m_features.texture_barrier = false;
60-
m_features.multidraw_fb_copy = GSConfig.OverrideTextureBarriers != 0;
60+
m_features.multidraw_fb_copy = false;
6161
m_features.provoking_vertex_last = false;
6262
m_features.point_expand = false;
6363
m_features.line_expand = false;
@@ -68,7 +68,8 @@ GSDevice11::GSDevice11()
6868
m_features.stencil_buffer = true;
6969
m_features.cas_sharpening = true;
7070
m_features.test_and_sample_depth = false;
71-
m_features.depth_feedback = true;
71+
m_features.depth_feedback = false;
72+
m_features.aa1 = false;
7273
}
7374

7475
GSDevice11::~GSDevice11() = default;
@@ -636,16 +637,19 @@ void GSDevice11::Destroy()
636637

637638
void GSDevice11::SetFeatures(IDXGIAdapter1* adapter)
638639
{
640+
// Check these first as others depend on them.
641+
m_features.multidraw_fb_copy = GSConfig.OverrideTextureBarriers != 0;
642+
m_features.vs_expand = (!GSConfig.DisableVertexShaderExpand && m_feature_level >= D3D_FEATURE_LEVEL_11_0);
643+
639644
// Check all three formats, since the feature means any can be used.
640645
m_features.dxt_textures = SupportsTextureFormat(m_dev.get(), DXGI_FORMAT_BC1_UNORM) &&
641646
SupportsTextureFormat(m_dev.get(), DXGI_FORMAT_BC2_UNORM) &&
642647
SupportsTextureFormat(m_dev.get(), DXGI_FORMAT_BC3_UNORM);
643648

644649
m_features.bptc_textures = SupportsTextureFormat(m_dev.get(), DXGI_FORMAT_BC7_UNORM);
645-
646-
m_features.vs_expand = (!GSConfig.DisableVertexShaderExpand && m_feature_level >= D3D_FEATURE_LEVEL_11_0);
647650
m_features.cas_sharpening = (m_feature_level >= D3D_FEATURE_LEVEL_11_0);
648651
m_features.test_and_sample_depth = (m_feature_level >= D3D_FEATURE_LEVEL_11_0);
652+
m_features.depth_feedback = m_features.feedback_loops();
649653
m_features.aa1 = GSConfig.HWAA1 && m_features.vs_expand && m_features.feedback_loops();
650654

651655
m_max_texture_size = (m_feature_level >= D3D_FEATURE_LEVEL_11_0) ?
@@ -2945,22 +2949,29 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config)
29452949
}
29462950

29472951
const bool tex_is_fb = config.tex && config.tex == draw_rt;
2952+
const bool rt_feedbackloop_pass1 = config.ps.IsFeedbackLoopRT() || tex_is_fb;
2953+
const bool rt_feedbackloop_pass2 = config.alpha_second_pass.ps.IsFeedbackLoopRT() || tex_is_fb;
29482954
if (draw_rt && (((config.require_one_barrier || (config.require_full_barrier && m_features.multidraw_fb_copy)) &&
2949-
(config.ps.IsFeedbackLoopRT() || config.alpha_second_pass.ps.IsFeedbackLoopRT())) || tex_is_fb))
2955+
(rt_feedbackloop_pass1 || rt_feedbackloop_pass2))))
29502956
{
29512957
config.require_one_barrier |= (tex_is_fb && !config.require_full_barrier);
2958+
config.alpha_second_pass.require_one_barrier |= (tex_is_fb && !config.require_full_barrier);
29522959

29532960
// Requires a copy of the RT.
29542961
draw_rt_clone = CreateTexture(rtsize.x, rtsize.y, 1, draw_rt->GetFormat(), true);
2962+
29552963
if (!draw_rt_clone)
29562964
Console.Warning("D3D11: Failed to allocate temp texture for RT copy.");
29572965
}
29582966

2959-
if (draw_ds && (config.require_one_barrier || (config.require_full_barrier && m_features.multidraw_fb_copy)) &&
2960-
m_features.depth_feedback && (config.ps.IsFeedbackLoopDepth() || config.alpha_second_pass.ps.IsFeedbackLoopDepth()))
2967+
const bool ds_feedbackloop_pass1 = config.ps.IsFeedbackLoopDepth();
2968+
const bool ds_feedbackloop_pass2 = config.alpha_second_pass.ps.IsFeedbackLoopDepth();
2969+
if (draw_ds && m_features.depth_feedback && (config.require_one_barrier || (config.require_full_barrier && m_features.multidraw_fb_copy)) &&
2970+
(ds_feedbackloop_pass1 || ds_feedbackloop_pass2))
29612971
{
29622972
// Requires a copy of the DS.
29632973
draw_ds_clone = CreateTexture(rtsize.x, rtsize.y, 1, draw_ds->GetFormat(), true);
2974+
29642975
if (!draw_ds_clone)
29652976
Console.Warning("D3D11: Failed to allocate temp texture for DS copy.");
29662977
}
@@ -2973,7 +2984,7 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config)
29732984
if (config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::StencilOne && need_barrier)
29742985
m_ctx->ClearDepthStencilView(*static_cast<GSTexture11*>(draw_ds), D3D11_CLEAR_STENCIL, 0.0f, 1);
29752986

2976-
SendHWDraw(config, draw_rt_clone, draw_rt, draw_ds_clone, draw_ds,
2987+
SendHWDraw(config, rt_feedbackloop_pass1 ? draw_rt_clone : nullptr, draw_rt, ds_feedbackloop_pass1 ? draw_ds_clone : nullptr, draw_ds,
29772988
config.require_one_barrier, config.require_full_barrier);
29782989

29792990
if (config.blend_multi_pass.enable)
@@ -3001,7 +3012,7 @@ void GSDevice11::RenderHW(GSHWDrawConfig& config)
30013012

30023013
const bool one_barrier = config.alpha_second_pass.require_one_barrier && m_features.multidraw_fb_copy;
30033014
SetupOM(config.alpha_second_pass.depth, OMBlendSelector(config.alpha_second_pass.colormask, config.blend), config.blend.constant);
3004-
SendHWDraw(config, draw_rt_clone, draw_rt, draw_ds_clone, draw_ds,
3015+
SendHWDraw(config, rt_feedbackloop_pass2 ? draw_rt_clone : nullptr, draw_rt, ds_feedbackloop_pass2 ? draw_ds_clone : nullptr, draw_ds,
30053016
one_barrier, config.alpha_second_pass.require_full_barrier);
30063017
}
30073018

pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,22 +2932,29 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config)
29322932
}
29332933

29342934
const bool tex_is_fb = config.tex && config.tex == draw_rt;
2935-
if (draw_rt && (((config.require_one_barrier || (config.require_full_barrier && m_features.multidraw_fb_copy)) &&
2936-
(config.ps.IsFeedbackLoopRT() || config.alpha_second_pass.ps.IsFeedbackLoopRT())) || tex_is_fb) && !m_features.texture_barrier)
2935+
const bool rt_feedbackloop_pass1 = config.ps.IsFeedbackLoopRT() || tex_is_fb;
2936+
const bool rt_feedbackloop_pass2 = config.alpha_second_pass.ps.IsFeedbackLoopRT() || tex_is_fb;
2937+
if (draw_rt && !m_features.texture_barrier && (((config.require_one_barrier || (config.require_full_barrier && m_features.multidraw_fb_copy)) &&
2938+
(rt_feedbackloop_pass1 || rt_feedbackloop_pass2))))
29372939
{
29382940
config.require_one_barrier |= (tex_is_fb && !config.require_full_barrier);
2941+
config.alpha_second_pass.require_one_barrier |= (tex_is_fb && !config.require_full_barrier);
29392942

29402943
// Requires a copy of the RT.
29412944
draw_rt_clone = CreateTexture(rtsize.x, rtsize.y, 1, draw_rt->GetFormat(), true);
2945+
29422946
if (!draw_rt_clone)
29432947
Console.Warning("GL: Failed to allocate temp texture for RT copy.");
29442948
}
29452949

2946-
if (draw_ds && (config.require_one_barrier || (config.require_full_barrier && m_features.multidraw_fb_copy)) &&
2947-
!m_features.texture_barrier && m_features.depth_feedback && (config.ps.IsFeedbackLoopDepth() || config.alpha_second_pass.ps.IsFeedbackLoopDepth()))
2950+
const bool ds_feedbackloop_pass1 = config.ps.IsFeedbackLoopDepth();
2951+
const bool ds_feedbackloop_pass2 = config.alpha_second_pass.ps.IsFeedbackLoopDepth();
2952+
if (draw_ds && !m_features.texture_barrier && m_features.depth_feedback &&
2953+
(config.require_one_barrier || (config.require_full_barrier && m_features.multidraw_fb_copy)) && (ds_feedbackloop_pass1 || ds_feedbackloop_pass2))
29482954
{
29492955
// Requires a copy of the DS.
29502956
draw_ds_clone = CreateTexture(rtsize.x, rtsize.y, 1, draw_ds->GetFormat(), true);
2957+
29512958
if (!draw_ds_clone)
29522959
Console.Warning("GL: Failed to allocate temp texture for DS copy.");
29532960
}
@@ -2963,7 +2970,7 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config)
29632970
glClearBufferiv(GL_STENCIL, 0, &clear_color);
29642971
}
29652972

2966-
SendHWDraw(config, draw_rt_clone, draw_rt, draw_ds_clone, draw_ds,
2973+
SendHWDraw(config, rt_feedbackloop_pass1 ? draw_rt_clone : nullptr, draw_rt, ds_feedbackloop_pass1 ? draw_ds_clone : nullptr, draw_ds,
29672974
config.require_one_barrier, config.require_full_barrier);
29682975

29692976
if (config.blend_multi_pass.enable)
@@ -3011,7 +3018,7 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config)
30113018
}
30123019
const bool one_barrier = config.alpha_second_pass.require_one_barrier && m_features.feedback_loops();
30133020
SetupOM(config.alpha_second_pass.depth);
3014-
SendHWDraw(config, draw_rt_clone, draw_rt, draw_ds_clone, draw_ds,
3021+
SendHWDraw(config, rt_feedbackloop_pass2 ? draw_rt_clone : nullptr, draw_rt, ds_feedbackloop_pass2 ? draw_ds_clone : nullptr, draw_ds,
30153022
one_barrier, config.alpha_second_pass.require_full_barrier);
30163023
}
30173024

0 commit comments

Comments
 (0)