video_core: multiple color attachments support

This commit is contained in:
psucien 2024-05-30 11:21:26 +02:00
parent 3741f013a3
commit 9227a2b868
3 changed files with 22 additions and 12 deletions

View File

@ -631,6 +631,10 @@ struct Liverpool {
u32 clear_word1; u32 clear_word1;
INSERT_PADDING_WORDS(2); INSERT_PADDING_WORDS(2);
operator bool() const {
return info.format != DataFormat::FormatInvalid;
}
u32 Pitch() const { u32 Pitch() const {
return (pitch.tile_max + 1) << 3; return (pitch.tile_max + 1) << 3;
} }

View File

@ -101,8 +101,7 @@ void PipelineCache::RefreshGraphicsKey() {
: vk::Format::eUndefined; : vk::Format::eUndefined;
for (u32 i = 0; i < Liverpool::NumColorBuffers; i++) { for (u32 i = 0; i < Liverpool::NumColorBuffers; i++) {
const auto& cb = regs.color_buffers[i]; const auto& cb = regs.color_buffers[i];
key.color_formats[i] = cb.base_address key.color_formats[i] = cb ? LiverpoolToVK::SurfaceFormat(cb.info.format, cb.NumFormat())
? LiverpoolToVK::SurfaceFormat(cb.info.format, cb.NumFormat())
: vk::Format::eUndefined; : vk::Format::eUndefined;
} }

View File

@ -39,14 +39,21 @@ void Rasterizer::Draw(bool is_indexed) {
const GraphicsPipeline* pipeline = pipeline_cache.GetGraphicsPipeline(); const GraphicsPipeline* pipeline = pipeline_cache.GetGraphicsPipeline();
pipeline->BindResources(memory, vertex_index_buffer, texture_cache); pipeline->BindResources(memory, vertex_index_buffer, texture_cache);
const auto& image_view = texture_cache.RenderTarget(regs.color_buffers[0]); boost::container::static_vector<vk::RenderingAttachmentInfo, Liverpool::NumColorBuffers>
color_attachments{};
for (const auto& col_buf : regs.color_buffers) {
if (!col_buf) {
continue;
}
const auto& image_view = texture_cache.RenderTarget(col_buf);
const vk::RenderingAttachmentInfo color_info = { color_attachments.push_back({
.imageView = *image_view.image_view, .imageView = *image_view.image_view,
.imageLayout = vk::ImageLayout::eGeneral, .imageLayout = vk::ImageLayout::eGeneral,
.loadOp = vk::AttachmentLoadOp::eLoad, .loadOp = vk::AttachmentLoadOp::eLoad,
.storeOp = vk::AttachmentStoreOp::eStore, .storeOp = vk::AttachmentStoreOp::eStore,
}; });
}
// TODO: Don't restart renderpass every draw // TODO: Don't restart renderpass every draw
const auto& scissor = regs.screen_scissor; const auto& scissor = regs.screen_scissor;
@ -57,8 +64,8 @@ void Rasterizer::Draw(bool is_indexed) {
.extent = {scissor.GetWidth(), scissor.GetHeight()}, .extent = {scissor.GetWidth(), scissor.GetHeight()},
}, },
.layerCount = 1, .layerCount = 1,
.colorAttachmentCount = 1, .colorAttachmentCount = static_cast<u32>(color_attachments.size()),
.pColorAttachments = &color_info, .pColorAttachments = color_attachments.data(),
}; };
UpdateDynamicState(); UpdateDynamicState();