Merge pull request #851 from shadps4-emu/stabilization/barriers
Some checks failed
Linux-Qt / build (push) Waiting to run
Linux / build (push) Waiting to run
macOS-Qt / build (push) Waiting to run
Windows-Qt / build (push) Waiting to run
Windows / build (push) Waiting to run
Reuse / reuse (push) Failing after 0s
Clang Format / clang-format (push) Failing after 0s

Various barrier fixes
This commit is contained in:
georgemoralis 2024-09-10 06:45:15 +03:00 committed by GitHub
commit 3a65052b8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 39 deletions

View File

@ -155,24 +155,6 @@ void Render(const vk::CommandBuffer& cmdbuf, ::Vulkan::Frame* frame) {
.pLabelName = "ImGui Render",
});
}
cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eColorAttachmentOutput,
vk::PipelineStageFlagBits::eColorAttachmentOutput, {}, {}, {},
{vk::ImageMemoryBarrier{
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite,
.dstAccessMask = vk::AccessFlagBits::eColorAttachmentRead,
.oldLayout = vk::ImageLayout::eUndefined,
.newLayout = vk::ImageLayout::eColorAttachmentOptimal,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = frame->image,
.subresourceRange{
.aspectMask = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = VK_REMAINING_ARRAY_LAYERS,
},
}});
vk::RenderingAttachmentInfo color_attachments[1]{
{

View File

@ -295,7 +295,7 @@ void RendererVulkan::Present(Frame* frame) {
vk::ImageMemoryBarrier{
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite,
.dstAccessMask = vk::AccessFlagBits::eTransferRead,
.oldLayout = vk::ImageLayout::eUndefined,
.oldLayout = vk::ImageLayout::eGeneral,
.newLayout = vk::ImageLayout::eTransferSrcOptimal,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,

View File

@ -114,11 +114,11 @@ ImageViewInfo::ImageViewInfo(const AmdGpu::Liverpool::DepthBuffer& depth_buffer,
}
ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info_, Image& image,
ImageId image_id_, std::optional<vk::ImageUsageFlags> usage_override /*= {}*/)
ImageId image_id_)
: image_id{image_id_}, info{info_} {
vk::ImageViewUsageCreateInfo usage_ci{};
if (usage_override) {
usage_ci.usage = usage_override.value();
vk::ImageViewUsageCreateInfo usage_ci{.usage = image.usage};
if (!info.is_storage) {
usage_ci.usage &= ~vk::ImageUsageFlagBits::eStorage;
}
// When sampling D32 texture from shader, the T# specifies R32 Float format so adjust it.
vk::Format format = info.format;
@ -134,7 +134,7 @@ ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info
}
const vk::ImageViewCreateInfo image_view_ci = {
.pNext = usage_override ? &usage_ci : nullptr,
.pNext = &usage_ci,
.image = image.image,
.viewType = info.type,
.format = instance.GetSupportedFormat(format),

View File

@ -8,8 +8,6 @@
#include "video_core/renderer_vulkan/vk_common.h"
#include "video_core/texture_cache/types.h"
#include <optional>
namespace Vulkan {
class Instance;
class Scheduler;
@ -28,7 +26,7 @@ struct ImageViewInfo {
vk::Format format = vk::Format::eR8G8B8A8Unorm;
SubresourceRange range;
vk::ComponentMapping mapping{};
bool is_storage;
bool is_storage = false;
auto operator<=>(const ImageViewInfo&) const = default;
};
@ -38,8 +36,8 @@ struct Image;
constexpr Common::SlotId NULL_IMAGE_VIEW_ID{0};
struct ImageView {
explicit ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info, Image& image,
ImageId image_id, std::optional<vk::ImageUsageFlags> usage_override = {});
ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info, Image& image,
ImageId image_id);
~ImageView();
ImageView(const ImageView&) = delete;

View File

@ -243,16 +243,7 @@ ImageView& TextureCache::RegisterImageView(ImageId image_id, const ImageViewInfo
return slot_image_views[view_id];
}
// All tiled images are created with storage usage flag. This makes set of formats (e.g. sRGB)
// impossible to use. However, during view creation, if an image isn't used as storage we can
// temporary remove its storage bit.
std::optional<vk::ImageUsageFlags> usage_override;
if (!image.info.usage.storage) {
usage_override = image.usage & ~vk::ImageUsageFlagBits::eStorage;
}
const ImageViewId view_id =
slot_image_views.insert(instance, view_info, image, image_id, usage_override);
const ImageViewId view_id = slot_image_views.insert(instance, view_info, image, image_id);
image.image_view_infos.emplace_back(view_info);
image.image_view_ids.emplace_back(view_id);
return slot_image_views[view_id];