mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-30 22:14:56 +00:00
vk_scheduler: Barrier attachments on renderpass end
This commit is contained in:
parent
e41281cb4a
commit
aad9c8049e
@ -127,6 +127,7 @@ void Rasterizer::BeginRendering() {
|
|||||||
state.height = std::min<u32>(state.height, image.info.size.height);
|
state.height = std::min<u32>(state.height, image.info.size.height);
|
||||||
|
|
||||||
const bool is_clear = texture_cache.IsMetaCleared(col_buf.CmaskAddress());
|
const bool is_clear = texture_cache.IsMetaCleared(col_buf.CmaskAddress());
|
||||||
|
state.color_images[state.num_color_attachments] = image.image;
|
||||||
state.color_attachments[state.num_color_attachments++] = {
|
state.color_attachments[state.num_color_attachments++] = {
|
||||||
.imageView = *image_view.image_view,
|
.imageView = *image_view.image_view,
|
||||||
.imageLayout = vk::ImageLayout::eGeneral,
|
.imageLayout = vk::ImageLayout::eGeneral,
|
||||||
@ -151,6 +152,7 @@ void Rasterizer::BeginRendering() {
|
|||||||
const auto& image = texture_cache.GetImage(image_view.image_id);
|
const auto& image = texture_cache.GetImage(image_view.image_id);
|
||||||
state.width = std::min<u32>(state.width, image.info.size.width);
|
state.width = std::min<u32>(state.width, image.info.size.width);
|
||||||
state.height = std::min<u32>(state.height, image.info.size.height);
|
state.height = std::min<u32>(state.height, image.info.size.height);
|
||||||
|
state.depth_image = image.image;
|
||||||
state.depth_attachment = {
|
state.depth_attachment = {
|
||||||
.imageView = *image_view.image_view,
|
.imageView = *image_view.image_view,
|
||||||
.imageLayout = image.layout,
|
.imageLayout = image.layout,
|
||||||
|
@ -50,7 +50,34 @@ void Scheduler::EndRendering() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
is_rendering = false;
|
is_rendering = false;
|
||||||
|
boost::container::static_vector<vk::ImageMemoryBarrier, 9> barriers;
|
||||||
|
for (size_t i = 0; i < render_state.num_color_attachments; ++i) {
|
||||||
|
barriers.push_back(vk::ImageMemoryBarrier{
|
||||||
|
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite,
|
||||||
|
.dstAccessMask = vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eShaderWrite |
|
||||||
|
vk::AccessFlagBits::eColorAttachmentRead |
|
||||||
|
vk::AccessFlagBits::eColorAttachmentWrite,
|
||||||
|
.oldLayout = vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
|
.newLayout = vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
|
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
|
.image = render_state.color_images[i],
|
||||||
|
.subresourceRange = {
|
||||||
|
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
|
.baseMipLevel = 0,
|
||||||
|
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||||
|
.baseArrayLayer = 0,
|
||||||
|
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
current_cmdbuf.endRendering();
|
current_cmdbuf.endRendering();
|
||||||
|
if (!barriers.empty()) {
|
||||||
|
current_cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eColorAttachmentOutput,
|
||||||
|
vk::PipelineStageFlagBits::eFragmentShader,
|
||||||
|
vk::DependencyFlagBits::eByRegion, {}, {}, barriers);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scheduler::Flush(SubmitInfo& info) {
|
void Scheduler::Flush(SubmitInfo& info) {
|
||||||
|
@ -15,7 +15,9 @@ class Instance;
|
|||||||
|
|
||||||
struct RenderState {
|
struct RenderState {
|
||||||
std::array<vk::RenderingAttachmentInfo, 8> color_attachments{};
|
std::array<vk::RenderingAttachmentInfo, 8> color_attachments{};
|
||||||
|
std::array<vk::Image, 8> color_images{};
|
||||||
vk::RenderingAttachmentInfo depth_attachment{};
|
vk::RenderingAttachmentInfo depth_attachment{};
|
||||||
|
vk::Image depth_image{};
|
||||||
u32 num_color_attachments{};
|
u32 num_color_attachments{};
|
||||||
u32 num_depth_attachments{};
|
u32 num_depth_attachments{};
|
||||||
u32 width = std::numeric_limits<u32>::max();
|
u32 width = std::numeric_limits<u32>::max();
|
||||||
|
@ -341,8 +341,7 @@ void TextureCache::RefreshImage(Image& image) {
|
|||||||
|
|
||||||
cmdbuf.copyBufferToImage(buffer, image.image, vk::ImageLayout::eTransferDstOptimal, image_copy);
|
cmdbuf.copyBufferToImage(buffer, image.image, vk::ImageLayout::eTransferDstOptimal, image_copy);
|
||||||
|
|
||||||
image.Transit(vk::ImageLayout::eGeneral,
|
image.Transit(vk::ImageLayout::eGeneral, vk::AccessFlagBits::eMemoryWrite | vk::AccessFlagBits::eMemoryRead);
|
||||||
vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eTransferRead);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::Sampler TextureCache::GetSampler(const AmdGpu::Sampler& sampler) {
|
vk::Sampler TextureCache::GetSampler(const AmdGpu::Sampler& sampler) {
|
||||||
|
Loading…
Reference in New Issue
Block a user