mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 15:18:45 +00:00
renderer_vulkan: initial HTile support
This commit is contained in:
parent
5b909c659d
commit
ff9850ca00
7 changed files with 20 additions and 12 deletions
|
@ -324,6 +324,10 @@ struct Liverpool {
|
||||||
BitField<0, 2, ZFormat> format;
|
BitField<0, 2, ZFormat> format;
|
||||||
BitField<2, 2, u32> num_samples;
|
BitField<2, 2, u32> num_samples;
|
||||||
BitField<13, 3, u32> tile_split;
|
BitField<13, 3, u32> tile_split;
|
||||||
|
BitField<27, 1, u32> allow_expclear;
|
||||||
|
BitField<28, 1, u32> read_size;
|
||||||
|
BitField<29, 1, u32> tile_surface_en;
|
||||||
|
BitField<31, 1, u32> zrange_precision;
|
||||||
} z_info;
|
} z_info;
|
||||||
union {
|
union {
|
||||||
BitField<0, 1, StencilFormat> format;
|
BitField<0, 1, StencilFormat> format;
|
||||||
|
|
|
@ -48,8 +48,6 @@ vk::Format DepthFormat(Liverpool::DepthBuffer::ZFormat z_format,
|
||||||
|
|
||||||
vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color_buffer);
|
vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color_buffer);
|
||||||
|
|
||||||
vk::ClearValue DepthClearValue();
|
|
||||||
|
|
||||||
void EmitQuadToTriangleListIndices(u8* out_indices, u32 num_vertices);
|
void EmitQuadToTriangleListIndices(u8* out_indices, u32 num_vertices);
|
||||||
|
|
||||||
} // namespace Vulkan::LiverpoolToVK
|
} // namespace Vulkan::LiverpoolToVK
|
||||||
|
|
|
@ -72,9 +72,11 @@ void Rasterizer::Draw(bool is_indexed, u32 index_offset) {
|
||||||
vk::RenderingAttachmentInfo depth_attachment{};
|
vk::RenderingAttachmentInfo depth_attachment{};
|
||||||
u32 num_depth_attachments{};
|
u32 num_depth_attachments{};
|
||||||
if (pipeline->IsDepthEnabled() && regs.depth_buffer.Address() != 0) {
|
if (pipeline->IsDepthEnabled() && regs.depth_buffer.Address() != 0) {
|
||||||
const bool is_clear = regs.depth_render_control.depth_clear_enable;
|
const auto htile_address = regs.depth_htile_data_base.GetAddress();
|
||||||
|
const bool is_clear = regs.depth_render_control.depth_clear_enable ||
|
||||||
|
texture_cache.IsMetaCleared(htile_address);
|
||||||
const auto& image_view =
|
const auto& image_view =
|
||||||
texture_cache.DepthTarget(regs.depth_buffer, liverpool->last_db_extent);
|
texture_cache.DepthTarget(regs.depth_buffer, htile_address, liverpool->last_db_extent);
|
||||||
depth_attachment = {
|
depth_attachment = {
|
||||||
.imageView = *image_view.image_view,
|
.imageView = *image_view.image_view,
|
||||||
.imageLayout = vk::ImageLayout::eGeneral,
|
.imageLayout = vk::ImageLayout::eGeneral,
|
||||||
|
@ -83,6 +85,7 @@ void Rasterizer::Draw(bool is_indexed, u32 index_offset) {
|
||||||
.clearValue = vk::ClearValue{.depthStencil = {.depth = regs.depth_clear,
|
.clearValue = vk::ClearValue{.depthStencil = {.depth = regs.depth_clear,
|
||||||
.stencil = regs.stencil_clear}},
|
.stencil = regs.stencil_clear}},
|
||||||
};
|
};
|
||||||
|
texture_cache.TouchMeta(htile_address, false);
|
||||||
num_depth_attachments++;
|
num_depth_attachments++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ ImageInfo::ImageInfo(const AmdGpu::Liverpool::ColorBuffer& buffer,
|
||||||
usage.render_target = true;
|
usage.render_target = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageInfo::ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer,
|
ImageInfo::ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer, VAddr htile_address,
|
||||||
const AmdGpu::Liverpool::CbDbExtent& hint) noexcept {
|
const AmdGpu::Liverpool::CbDbExtent& hint) noexcept {
|
||||||
is_tiled = false;
|
is_tiled = false;
|
||||||
pixel_format = LiverpoolToVK::DepthFormat(buffer.z_info.format, buffer.stencil_info.format);
|
pixel_format = LiverpoolToVK::DepthFormat(buffer.z_info.format, buffer.stencil_info.format);
|
||||||
|
@ -165,6 +165,7 @@ ImageInfo::ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer,
|
||||||
size.depth = 1;
|
size.depth = 1;
|
||||||
pitch = size.width;
|
pitch = size.width;
|
||||||
guest_size_bytes = buffer.GetSizeAligned();
|
guest_size_bytes = buffer.GetSizeAligned();
|
||||||
|
meta_info.htile_addr = buffer.z_info.tile_surface_en ? htile_address : 0;
|
||||||
usage.depth_target = true;
|
usage.depth_target = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ struct ImageInfo {
|
||||||
explicit ImageInfo(const Libraries::VideoOut::BufferAttributeGroup& group) noexcept;
|
explicit ImageInfo(const Libraries::VideoOut::BufferAttributeGroup& group) noexcept;
|
||||||
explicit ImageInfo(const AmdGpu::Liverpool::ColorBuffer& buffer,
|
explicit ImageInfo(const AmdGpu::Liverpool::ColorBuffer& buffer,
|
||||||
const AmdGpu::Liverpool::CbDbExtent& hint = {}) noexcept;
|
const AmdGpu::Liverpool::CbDbExtent& hint = {}) noexcept;
|
||||||
explicit ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer,
|
explicit ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer, VAddr htile_address,
|
||||||
const AmdGpu::Liverpool::CbDbExtent& hint = {}) noexcept;
|
const AmdGpu::Liverpool::CbDbExtent& hint = {}) noexcept;
|
||||||
explicit ImageInfo(const AmdGpu::Image& image) noexcept;
|
explicit ImageInfo(const AmdGpu::Image& image) noexcept;
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ struct ImageInfo {
|
||||||
bool IsDepthStencil() const;
|
bool IsDepthStencil() const;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
VAddr cmask_addr{};
|
VAddr cmask_addr;
|
||||||
VAddr fmask_addr{};
|
VAddr fmask_addr;
|
||||||
VAddr htile_addr{};
|
VAddr htile_addr;
|
||||||
} meta_info;
|
} meta_info{};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u32 texture : 1;
|
u32 texture : 1;
|
||||||
|
@ -62,7 +62,7 @@ struct ImageInfo {
|
||||||
u32 render_target : 1;
|
u32 render_target : 1;
|
||||||
u32 depth_target : 1;
|
u32 depth_target : 1;
|
||||||
u32 vo_buffer : 1;
|
u32 vo_buffer : 1;
|
||||||
} usage; // Usage data tracked during image lifetime
|
} usage{}; // Usage data tracked during image lifetime
|
||||||
|
|
||||||
bool is_tiled = false;
|
bool is_tiled = false;
|
||||||
vk::Format pixel_format = vk::Format::eUndefined;
|
vk::Format pixel_format = vk::Format::eUndefined;
|
||||||
|
|
|
@ -195,8 +195,9 @@ ImageView& TextureCache::RenderTarget(const AmdGpu::Liverpool::ColorBuffer& buff
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView& TextureCache::DepthTarget(const AmdGpu::Liverpool::DepthBuffer& buffer,
|
ImageView& TextureCache::DepthTarget(const AmdGpu::Liverpool::DepthBuffer& buffer,
|
||||||
|
VAddr htile_address,
|
||||||
const AmdGpu::Liverpool::CbDbExtent& hint) {
|
const AmdGpu::Liverpool::CbDbExtent& hint) {
|
||||||
const ImageInfo info{buffer, hint};
|
const ImageInfo info{buffer, htile_address, hint};
|
||||||
auto& image = FindImage(info, buffer.Address(), false);
|
auto& image = FindImage(info, buffer.Address(), false);
|
||||||
image.flags &= ~ImageFlagBits::CpuModified;
|
image.flags &= ~ImageFlagBits::CpuModified;
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
[[nodiscard]] ImageView& RenderTarget(const AmdGpu::Liverpool::ColorBuffer& buffer,
|
[[nodiscard]] ImageView& RenderTarget(const AmdGpu::Liverpool::ColorBuffer& buffer,
|
||||||
const AmdGpu::Liverpool::CbDbExtent& hint);
|
const AmdGpu::Liverpool::CbDbExtent& hint);
|
||||||
[[nodiscard]] ImageView& DepthTarget(const AmdGpu::Liverpool::DepthBuffer& buffer,
|
[[nodiscard]] ImageView& DepthTarget(const AmdGpu::Liverpool::DepthBuffer& buffer,
|
||||||
|
VAddr htile_address,
|
||||||
const AmdGpu::Liverpool::CbDbExtent& hint);
|
const AmdGpu::Liverpool::CbDbExtent& hint);
|
||||||
|
|
||||||
/// Reuploads image contents.
|
/// Reuploads image contents.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue