Surface management rework (1/3) (#307)

* amdgpu: proper CB and DB sizes calculation; minor refactoring

* texture_cache: separate file for image_info

* texture_cache: image guest address moved into image info

* texture_cache: surface size calculation

* shader_recompiler: fixed sin/cos

Thanks to red_pring and gandalfthewhite0173

* initial preparations for subresources upload

* review comments
This commit is contained in:
psucien 2024-07-20 11:51:21 +02:00 committed by GitHub
parent 2b52a17845
commit 64459f1a76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 467 additions and 233 deletions

View file

@ -505,7 +505,7 @@ vk::Format DepthFormat(DepthBuffer::ZFormat z_format, DepthBuffer::StencilFormat
stencil_format == DepthBuffer::StencilFormat::Stencil8) {
return vk::Format::eD16UnormS8Uint;
}
if (z_format == DepthBuffer::ZFormat::Invald &&
if (z_format == DepthBuffer::ZFormat::Invalid &&
stencil_format == DepthBuffer::StencilFormat::Invalid) {
return vk::Format::eUndefined;
}

View file

@ -182,8 +182,9 @@ bool RendererVulkan::ShowSplash(Frame* frame /*= nullptr*/) {
info.size =
VideoCore::Extent3D{splash->GetImageInfo().width, splash->GetImageInfo().height, 1};
info.pitch = splash->GetImageInfo().width;
info.guest_address = VAddr(splash->GetImageData().data());
info.guest_size_bytes = splash->GetImageData().size();
splash_img.emplace(instance, scheduler, info, VAddr(splash->GetImageData().data()));
splash_img.emplace(instance, scheduler, info);
texture_cache.RefreshImage(*splash_img);
}
frame = PrepareFrameInternal(*splash_img);

View file

@ -40,7 +40,7 @@ public:
Frame* PrepareFrame(const Libraries::VideoOut::BufferAttributeGroup& attribute,
VAddr cpu_address) {
const auto info = VideoCore::ImageInfo{attribute};
const auto info = VideoCore::ImageInfo{attribute, cpu_address};
const auto image_id = texture_cache.FindImage(info, cpu_address);
auto& image = texture_cache.GetImage(image_id);
return PrepareFrameInternal(image);
@ -54,7 +54,7 @@ public:
VideoCore::Image& RegisterVideoOutSurface(
const Libraries::VideoOut::BufferAttributeGroup& attribute, VAddr cpu_address) {
vo_buffers_addr.emplace_back(cpu_address);
const auto info = VideoCore::ImageInfo{attribute};
const auto info = VideoCore::ImageInfo{attribute, cpu_address};
const auto image_id = texture_cache.FindImage(info, cpu_address);
return texture_cache.GetImage(image_id);
}

View file

@ -128,7 +128,7 @@ bool ComputePipeline::BindResources(Core::MemoryManager* memory, StreamBuffer& s
for (const auto& image_desc : info.images) {
const auto tsharp =
info.ReadUd<AmdGpu::Image>(image_desc.sgpr_base, image_desc.dword_offset);
const auto& image_view = texture_cache.FindImageView(tsharp, image_desc.is_storage);
const auto& image_view = texture_cache.FindTexture(tsharp, image_desc.is_storage);
const auto& image = texture_cache.GetImage(image_view.image_id);
image_infos.emplace_back(VK_NULL_HANDLE, *image_view.image_view, image.layout);
set_writes.push_back({

View file

@ -366,7 +366,7 @@ void GraphicsPipeline::BindResources(Core::MemoryManager* memory, StreamBuffer&
for (const auto& image_desc : stage.images) {
const auto& tsharp = tsharps.emplace_back(
stage.ReadUd<AmdGpu::Image>(image_desc.sgpr_base, image_desc.dword_offset));
const auto& image_view = texture_cache.FindImageView(tsharp, image_desc.is_storage);
const auto& image_view = texture_cache.FindTexture(tsharp, image_desc.is_storage);
const auto& image = texture_cache.GetImage(image_view.image_id);
image_infos.emplace_back(VK_NULL_HANDLE, *image_view.image_view, image.layout);
set_writes.push_back({

View file

@ -113,7 +113,7 @@ void Rasterizer::BeginRendering() {
}
const auto& hint = liverpool->last_cb_extent[col_buf_id];
const auto& image_view = texture_cache.RenderTarget(col_buf, hint);
const auto& image_view = texture_cache.FindRenderTarget(col_buf, hint);
const auto& image = texture_cache.GetImage(image_view.image_id);
state.width = std::min<u32>(state.width, image.info.size.width);
state.height = std::min<u32>(state.height, image.info.size.height);
@ -130,14 +130,15 @@ void Rasterizer::BeginRendering() {
texture_cache.TouchMeta(col_buf.CmaskAddress(), false);
}
if (regs.depth_buffer.z_info.format != Liverpool::DepthBuffer::ZFormat::Invald &&
if (regs.depth_buffer.z_info.format != Liverpool::DepthBuffer::ZFormat::Invalid &&
regs.depth_buffer.Address() != 0) {
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& hint = liverpool->last_db_extent;
const auto& image_view = texture_cache.DepthTarget(regs.depth_buffer, htile_address, hint,
regs.depth_control.depth_write_enable);
const auto& image_view = texture_cache.FindDepthTarget(
regs.depth_buffer, regs.depth_view.NumSlices(), htile_address, hint,
regs.depth_control.depth_write_enable);
const auto& image = texture_cache.GetImage(image_view.image_id);
state.width = std::min<u32>(state.width, image.info.size.width);
state.height = std::min<u32>(state.height, image.info.size.height);