summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-04-23 02:05:10 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:29 +0200
commit7a1f296cda32bdb8996f25fd1862b422ac2bfe48 (patch)
tree521d086aeb329efbbdf6d906a7978aad7b1e360b
parentshader: Increase the maximum number of storage buffers (diff)
downloadyuzu-7a1f296cda32bdb8996f25fd1862b422ac2bfe48.tar
yuzu-7a1f296cda32bdb8996f25fd1862b422ac2bfe48.tar.gz
yuzu-7a1f296cda32bdb8996f25fd1862b422ac2bfe48.tar.bz2
yuzu-7a1f296cda32bdb8996f25fd1862b422ac2bfe48.tar.lz
yuzu-7a1f296cda32bdb8996f25fd1862b422ac2bfe48.tar.xz
yuzu-7a1f296cda32bdb8996f25fd1862b422ac2bfe48.tar.zst
yuzu-7a1f296cda32bdb8996f25fd1862b422ac2bfe48.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp18
-rw-r--r--src/video_core/renderer_vulkan/vk_render_pass_cache.cpp42
2 files changed, 34 insertions, 26 deletions
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
index b7688aef9..e43db280f 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
@@ -105,6 +105,17 @@ RenderPassKey MakeRenderPassKey(const FixedPipelineState& state) {
key.samples = MaxwellToVK::MsaaMode(state.msaa_mode);
return key;
}
+
+size_t NumAttachments(const FixedPipelineState& state) {
+ size_t num{};
+ for (size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
+ const auto format{static_cast<Tegra::RenderTargetFormat>(state.color_formats[index])};
+ if (format != Tegra::RenderTargetFormat::NONE) {
+ num = index + 1;
+ }
+ }
+ return num;
+}
} // Anonymous namespace
GraphicsPipeline::GraphicsPipeline(Tegra::Engines::Maxwell3D& maxwell3d_,
@@ -418,17 +429,14 @@ void GraphicsPipeline::MakePipeline(const Device& device, VkRenderPass render_pa
.maxDepthBounds = 0.0f,
};
static_vector<VkPipelineColorBlendAttachmentState, Maxwell::NumRenderTargets> cb_attachments;
- for (size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
+ const size_t num_attachments{NumAttachments(state)};
+ for (size_t index = 0; index < num_attachments; ++index) {
static constexpr std::array mask_table{
VK_COLOR_COMPONENT_R_BIT,
VK_COLOR_COMPONENT_G_BIT,
VK_COLOR_COMPONENT_B_BIT,
VK_COLOR_COMPONENT_A_BIT,
};
- const auto format{static_cast<Tegra::RenderTargetFormat>(state.color_formats[index])};
- if (format == Tegra::RenderTargetFormat::NONE) {
- continue;
- }
const auto& blend{state.attachments[index]};
const std::array mask{blend.Mask()};
VkColorComponentFlags write_mask{};
diff --git a/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp b/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp
index 991afe521..451ffe019 100644
--- a/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_render_pass_cache.cpp
@@ -16,18 +16,6 @@ namespace Vulkan {
namespace {
using VideoCore::Surface::PixelFormat;
-constexpr std::array ATTACHMENT_REFERENCES{
- VkAttachmentReference{0, VK_IMAGE_LAYOUT_GENERAL},
- VkAttachmentReference{1, VK_IMAGE_LAYOUT_GENERAL},
- VkAttachmentReference{2, VK_IMAGE_LAYOUT_GENERAL},
- VkAttachmentReference{3, VK_IMAGE_LAYOUT_GENERAL},
- VkAttachmentReference{4, VK_IMAGE_LAYOUT_GENERAL},
- VkAttachmentReference{5, VK_IMAGE_LAYOUT_GENERAL},
- VkAttachmentReference{6, VK_IMAGE_LAYOUT_GENERAL},
- VkAttachmentReference{7, VK_IMAGE_LAYOUT_GENERAL},
- VkAttachmentReference{8, VK_IMAGE_LAYOUT_GENERAL},
-};
-
VkAttachmentDescription AttachmentDescription(const Device& device, PixelFormat format,
VkSampleCountFlagBits samples) {
using MaxwellToVK::SurfaceFormat;
@@ -54,17 +42,29 @@ VkRenderPass RenderPassCache::Get(const RenderPassKey& key) {
return *pair->second;
}
boost::container::static_vector<VkAttachmentDescription, 9> descriptions;
+ std::array<VkAttachmentReference, 8> references{};
+ u32 num_attachments{};
+ u32 num_colors{};
for (size_t index = 0; index < key.color_formats.size(); ++index) {
const PixelFormat format{key.color_formats[index]};
- if (format == PixelFormat::Invalid) {
- continue;
+ const bool is_valid{format != PixelFormat::Invalid};
+ references[index] = VkAttachmentReference{
+ .attachment = is_valid ? num_colors : VK_ATTACHMENT_UNUSED,
+ .layout = VK_IMAGE_LAYOUT_GENERAL,
+ };
+ if (is_valid) {
+ descriptions.push_back(AttachmentDescription(*device, format, key.samples));
+ num_attachments = static_cast<u32>(index + 1);
+ ++num_colors;
}
- descriptions.push_back(AttachmentDescription(*device, format, key.samples));
}
- const size_t num_colors{descriptions.size()};
- const VkAttachmentReference* depth_attachment{};
+ const bool has_depth{key.depth_format != PixelFormat::Invalid};
+ VkAttachmentReference depth_reference{};
if (key.depth_format != PixelFormat::Invalid) {
- depth_attachment = &ATTACHMENT_REFERENCES[num_colors];
+ depth_reference = VkAttachmentReference{
+ .attachment = num_colors,
+ .layout = VK_IMAGE_LAYOUT_GENERAL,
+ };
descriptions.push_back(AttachmentDescription(*device, key.depth_format, key.samples));
}
const VkSubpassDescription subpass{
@@ -72,10 +72,10 @@ VkRenderPass RenderPassCache::Get(const RenderPassKey& key) {
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.inputAttachmentCount = 0,
.pInputAttachments = nullptr,
- .colorAttachmentCount = static_cast<u32>(num_colors),
- .pColorAttachments = num_colors != 0 ? ATTACHMENT_REFERENCES.data() : nullptr,
+ .colorAttachmentCount = num_attachments,
+ .pColorAttachments = references.data(),
.pResolveAttachments = nullptr,
- .pDepthStencilAttachment = depth_attachment,
+ .pDepthStencilAttachment = has_depth ? &depth_reference : nullptr,
.preserveAttachmentCount = 0,
.pPreserveAttachments = nullptr,
};