Skip to content

Commit 063a8d6

Browse files
committed
Revert "renderer_vulkan: Handle depth-stencil copies through depth render overrides. (shadps4-emu#2134)"
This reverts commit 5040be1. # Conflicts: # src/video_core/renderer_vulkan/vk_rasterizer.cpp
1 parent 76436f2 commit 063a8d6

File tree

8 files changed

+13
-153
lines changed

8 files changed

+13
-153
lines changed

src/core/devtools/widget/reg_popup.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ void RegPopup::DrawDepthBuffer(const DepthBuffer& depth_data) {
105105
"DEPTH_SLICE.TILE_MAX", depth_buffer.depth_slice.tile_max,
106106
"Pitch()", depth_buffer.Pitch(),
107107
"Height()", depth_buffer.Height(),
108-
"DepthAddress()", depth_buffer.DepthAddress(),
109-
"StencilAddress()", depth_buffer.StencilAddress(),
108+
"Address()", depth_buffer.Address(),
110109
"NumSamples()", depth_buffer.NumSamples(),
111110
"NumBits()", depth_buffer.NumBits(),
112111
"GetDepthSliceSize()", depth_buffer.GetDepthSliceSize()

src/core/devtools/widget/reg_view.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void RegView::DrawGraphicsRegs() {
155155
TableNextColumn();
156156
TextUnformatted("Depth buffer");
157157
TableNextColumn();
158-
if (regs.depth_buffer.DepthAddress() == 0 || !regs.depth_control.depth_enable) {
158+
if (regs.depth_buffer.Address() == 0 || !regs.depth_control.depth_enable) {
159159
TextUnformatted("N/A");
160160
} else {
161161
const char* text = last_selected_cb == depth_id && default_reg_popup.open ? "x" : "->";
@@ -241,7 +241,7 @@ void RegView::SetData(DebugStateType::RegDump _data, const std::string& base_tit
241241
default_reg_popup.open = false;
242242
if (last_selected_cb == depth_id) {
243243
const auto& has_depth =
244-
regs.depth_buffer.DepthAddress() != 0 && regs.depth_control.depth_enable;
244+
regs.depth_buffer.Address() != 0 && regs.depth_control.depth_enable;
245245
if (has_depth) {
246246
default_reg_popup.SetData(title, regs.depth_buffer, regs.depth_control);
247247
default_reg_popup.open = true;

src/video_core/amdgpu/liverpool.h

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -433,19 +433,11 @@ struct Liverpool {
433433
} depth_slice;
434434

435435
bool DepthValid() const {
436-
return DepthAddress() != 0 && z_info.format != ZFormat::Invalid;
436+
return Address() != 0 && z_info.format != ZFormat::Invalid;
437437
}
438438

439439
bool StencilValid() const {
440-
return StencilAddress() != 0 && stencil_info.format != StencilFormat::Invalid;
441-
}
442-
443-
bool DepthWriteValid() const {
444-
return DepthWriteAddress() != 0 && z_info.format != ZFormat::Invalid;
445-
}
446-
447-
bool StencilWriteValid() const {
448-
return StencilWriteAddress() != 0 && stencil_info.format != StencilFormat::Invalid;
440+
return Address() != 0 && stencil_info.format != StencilFormat::Invalid;
449441
}
450442

451443
u32 Pitch() const {
@@ -456,22 +448,14 @@ struct Liverpool {
456448
return (depth_size.height_tile_max + 1) << 3;
457449
}
458450

459-
u64 DepthAddress() const {
451+
u64 Address() const {
460452
return u64(z_read_base) << 8;
461453
}
462454

463455
u64 StencilAddress() const {
464456
return u64(stencil_read_base) << 8;
465457
}
466458

467-
u64 DepthWriteAddress() const {
468-
return u64(z_write_base) << 8;
469-
}
470-
471-
u64 StencilWriteAddress() const {
472-
return u64(stencil_write_base) << 8;
473-
}
474-
475459
u32 NumSamples() const {
476460
return 1u << z_info.num_samples; // spec doesn't say it is a log2
477461
}
@@ -1028,46 +1012,6 @@ struct Liverpool {
10281012
}
10291013
};
10301014

1031-
enum class ForceEnable : u32 {
1032-
Off = 0,
1033-
Enable = 1,
1034-
Disable = 2,
1035-
};
1036-
1037-
enum class ForceSumm : u32 {
1038-
Off = 0,
1039-
MinZ = 1,
1040-
MaxZ = 2,
1041-
Both = 3,
1042-
};
1043-
1044-
union DepthRenderOverride {
1045-
u32 raw;
1046-
BitField<0, 2, ForceEnable> force_hiz_enable;
1047-
BitField<2, 2, ForceEnable> force_his_enable0;
1048-
BitField<4, 2, ForceEnable> force_his_enable1;
1049-
BitField<6, 1, u32> force_shader_z_order;
1050-
BitField<7, 1, u32> fast_z_disable;
1051-
BitField<8, 1, u32> fast_stencil_disable;
1052-
BitField<9, 1, u32> noop_cull_disable;
1053-
BitField<10, 1, u32> force_color_kill;
1054-
BitField<11, 1, u32> force_z_read;
1055-
BitField<12, 1, u32> force_stencil_read;
1056-
BitField<13, 2, ForceEnable> force_full_z_range;
1057-
BitField<15, 1, u32> force_qc_smask_conflict;
1058-
BitField<16, 1, u32> disable_viewport_clamp;
1059-
BitField<17, 1, u32> ignore_sc_zrange;
1060-
BitField<18, 1, u32> disable_fully_covered;
1061-
BitField<19, 2, ForceSumm> force_z_limit_summ;
1062-
BitField<21, 5, u32> max_tiles_in_dtt;
1063-
BitField<26, 1, u32> disable_tile_rate_tiles;
1064-
BitField<27, 1, u32> force_z_dirty;
1065-
BitField<28, 1, u32> force_stencil_dirty;
1066-
BitField<29, 1, u32> force_z_valid;
1067-
BitField<30, 1, u32> force_stencil_valid;
1068-
BitField<31, 1, u32> preserve_compression;
1069-
};
1070-
10711015
union AaConfig {
10721016
BitField<0, 3, u32> msaa_num_samples;
10731017
BitField<4, 1, u32> aa_mask_centroid_dtmn;
@@ -1269,8 +1213,7 @@ struct Liverpool {
12691213
DepthRenderControl depth_render_control;
12701214
INSERT_PADDING_WORDS(1);
12711215
DepthView depth_view;
1272-
DepthRenderOverride depth_render_override;
1273-
INSERT_PADDING_WORDS(1);
1216+
INSERT_PADDING_WORDS(2);
12741217
Address depth_htile_data_base;
12751218
INSERT_PADDING_WORDS(2);
12761219
float depth_bounds_min;

src/video_core/renderer_vulkan/vk_rasterizer.cpp

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,6 @@ bool Rasterizer::FilterDraw() {
7272
return false;
7373
}
7474

75-
const bool cb_disabled =
76-
regs.color_control.mode == AmdGpu::Liverpool::ColorControl::OperationMode::Disable;
77-
const auto depth_copy =
78-
regs.depth_render_override.force_z_dirty && regs.depth_render_override.force_z_valid &&
79-
regs.depth_buffer.DepthValid() && regs.depth_buffer.DepthWriteValid() &&
80-
regs.depth_buffer.DepthAddress() != regs.depth_buffer.DepthWriteAddress();
81-
const auto stencil_copy =
82-
regs.depth_render_override.force_stencil_dirty &&
83-
regs.depth_render_override.force_stencil_valid && regs.depth_buffer.StencilValid() &&
84-
regs.depth_buffer.StencilWriteValid() &&
85-
regs.depth_buffer.StencilAddress() != regs.depth_buffer.StencilWriteAddress();
86-
if (cb_disabled && (depth_copy || stencil_copy)) {
87-
// Games may disable color buffer and enable force depth/stencil dirty and valid to
88-
// do a copy from one depth-stencil surface to another, without a pixel shader.
89-
// We need to detect this case and perform the copy, otherwise it will have no effect.
90-
LOG_TRACE(Render_Vulkan, "Performing depth-stencil override copy");
91-
DepthStencilCopy(depth_copy, stencil_copy);
92-
return false;
93-
}
94-
9575
return true;
9676
}
9777

@@ -942,66 +922,6 @@ void Rasterizer::Resolve() {
942922
ScopeMarkerEnd();
943923
}
944924

945-
void Rasterizer::DepthStencilCopy(bool is_depth, bool is_stencil) {
946-
auto& regs = liverpool->regs;
947-
948-
auto read_desc = VideoCore::TextureCache::DepthTargetDesc(
949-
regs.depth_buffer, regs.depth_view, regs.depth_control,
950-
regs.depth_htile_data_base.GetAddress(), liverpool->last_db_extent, false);
951-
auto write_desc = VideoCore::TextureCache::DepthTargetDesc(
952-
regs.depth_buffer, regs.depth_view, regs.depth_control,
953-
regs.depth_htile_data_base.GetAddress(), liverpool->last_db_extent, true);
954-
955-
auto& read_image = texture_cache.GetImage(texture_cache.FindImage(read_desc));
956-
auto& write_image = texture_cache.GetImage(texture_cache.FindImage(write_desc));
957-
958-
VideoCore::SubresourceRange sub_range;
959-
sub_range.base.layer = liverpool->regs.depth_view.slice_start;
960-
sub_range.extent.layers = liverpool->regs.depth_view.NumSlices() - sub_range.base.layer;
961-
962-
ScopeMarkerBegin(fmt::format(
963-
"DepthStencilCopy:DR={:#x}:SR={:#x}:DW={:#x}:SW={:#x}", regs.depth_buffer.DepthAddress(),
964-
regs.depth_buffer.StencilAddress(), regs.depth_buffer.DepthWriteAddress(),
965-
regs.depth_buffer.StencilWriteAddress()));
966-
967-
read_image.Transit(vk::ImageLayout::eTransferSrcOptimal, vk::AccessFlagBits2::eTransferRead,
968-
sub_range);
969-
write_image.Transit(vk::ImageLayout::eTransferDstOptimal, vk::AccessFlagBits2::eTransferWrite,
970-
sub_range);
971-
972-
auto aspect_mask = vk::ImageAspectFlags(0);
973-
if (is_depth) {
974-
aspect_mask |= vk::ImageAspectFlagBits::eDepth;
975-
}
976-
if (is_stencil) {
977-
aspect_mask |= vk::ImageAspectFlagBits::eStencil;
978-
}
979-
vk::ImageCopy region = {
980-
.srcSubresource =
981-
{
982-
.aspectMask = aspect_mask,
983-
.mipLevel = 0,
984-
.baseArrayLayer = sub_range.base.layer,
985-
.layerCount = sub_range.extent.layers,
986-
},
987-
.srcOffset = {0, 0, 0},
988-
.dstSubresource =
989-
{
990-
.aspectMask = aspect_mask,
991-
.mipLevel = 0,
992-
.baseArrayLayer = sub_range.base.layer,
993-
.layerCount = sub_range.extent.layers,
994-
},
995-
.dstOffset = {0, 0, 0},
996-
.extent = {write_image.info.size.width, write_image.info.size.height, 1},
997-
};
998-
scheduler.CommandBuffer().copyImage(read_image.image, vk::ImageLayout::eTransferSrcOptimal,
999-
write_image.image, vk::ImageLayout::eTransferDstOptimal,
1000-
region);
1001-
1002-
ScopeMarkerEnd();
1003-
}
1004-
1005925
void Rasterizer::InlineData(VAddr address, const void* value, u32 num_bytes, bool is_gds) {
1006926
buffer_cache.InlineData(address, value, num_bytes, is_gds);
1007927
}

src/video_core/renderer_vulkan/vk_rasterizer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class Rasterizer {
7272
RenderState PrepareRenderState(u32 mrt_mask);
7373
void BeginRendering(const GraphicsPipeline& pipeline, RenderState& state);
7474
void Resolve();
75-
void DepthStencilCopy(bool is_depth, bool is_stencil);
7675
void EliminateFastClear();
7776

7877
void UpdateDynamicState(const GraphicsPipeline& pipeline);

src/video_core/texture_cache/image_info.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ ImageInfo::ImageInfo(const AmdGpu::Liverpool::ColorBuffer& buffer,
9898
}
9999

100100
ImageInfo::ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer, u32 num_slices,
101-
VAddr htile_address, const AmdGpu::Liverpool::CbDbExtent& hint,
102-
bool write_buffer) noexcept {
101+
VAddr htile_address, const AmdGpu::Liverpool::CbDbExtent& hint) noexcept {
103102
props.is_tiled = false;
104103
pixel_format = LiverpoolToVK::DepthFormat(buffer.z_info.format, buffer.stencil_info.format);
105104
type = vk::ImageType::e2D;
@@ -112,10 +111,10 @@ ImageInfo::ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer, u32 num_slice
112111
resources.layers = num_slices;
113112
meta_info.htile_addr = buffer.z_info.tile_surface_en ? htile_address : 0;
114113

115-
stencil_addr = write_buffer ? buffer.StencilWriteAddress() : buffer.StencilAddress();
114+
stencil_addr = buffer.StencilAddress();
116115
stencil_size = pitch * size.height * sizeof(u8);
117116

118-
guest_address = write_buffer ? buffer.DepthWriteAddress() : buffer.DepthAddress();
117+
guest_address = buffer.Address();
119118
const auto depth_slice_sz = buffer.GetDepthSliceSize();
120119
guest_size = depth_slice_sz * num_slices;
121120
mips_layout.emplace_back(depth_slice_sz, pitch, 0);

src/video_core/texture_cache/image_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct ImageInfo {
1919
ImageInfo(const AmdGpu::Liverpool::ColorBuffer& buffer,
2020
const AmdGpu::Liverpool::CbDbExtent& hint = {}) noexcept;
2121
ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer, u32 num_slices, VAddr htile_address,
22-
const AmdGpu::Liverpool::CbDbExtent& hint = {}, bool write_buffer = false) noexcept;
22+
const AmdGpu::Liverpool::CbDbExtent& hint = {}) noexcept;
2323
ImageInfo(const AmdGpu::Image& image, const Shader::ImageResource& desc) noexcept;
2424

2525
bool IsTiled() const {

src/video_core/texture_cache/texture_cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class TextureCache {
7979
DepthTargetDesc(const AmdGpu::Liverpool::DepthBuffer& buffer,
8080
const AmdGpu::Liverpool::DepthView& view,
8181
const AmdGpu::Liverpool::DepthControl& ctl, VAddr htile_address,
82-
const AmdGpu::Liverpool::CbDbExtent& hint = {}, bool write_buffer = false)
82+
const AmdGpu::Liverpool::CbDbExtent& hint = {})
8383
: BaseDesc{BindingType::DepthTarget,
84-
ImageInfo{buffer, view.NumSlices(), htile_address, hint, write_buffer},
84+
ImageInfo{buffer, view.NumSlices(), htile_address, hint},
8585
ImageViewInfo{buffer, view, ctl}} {}
8686
};
8787

0 commit comments

Comments
 (0)