diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-01-07 01:18:38 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-01-07 02:02:26 +0100 |
commit | b392a5986ea305d805d259e414f8fb5ecc0f80b4 (patch) | |
tree | d5d670e505b4fff0a19f1e9533e4eb9d079e64d6 /src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |
parent | fixed_pipeline_state: Add depth clamp (diff) | |
download | yuzu-b392a5986ea305d805d259e414f8fb5ecc0f80b4.tar yuzu-b392a5986ea305d805d259e414f8fb5ecc0f80b4.tar.gz yuzu-b392a5986ea305d805d259e414f8fb5ecc0f80b4.tar.bz2 yuzu-b392a5986ea305d805d259e414f8fb5ecc0f80b4.tar.lz yuzu-b392a5986ea305d805d259e414f8fb5ecc0f80b4.tar.xz yuzu-b392a5986ea305d805d259e414f8fb5ecc0f80b4.tar.zst yuzu-b392a5986ea305d805d259e414f8fb5ecc0f80b4.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan/vk_pipeline_cache.cpp')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp new file mode 100644 index 000000000..9bc027cbf --- /dev/null +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -0,0 +1,43 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <cstddef> +#include <vector> + +#include "video_core/renderer_vulkan/declarations.h" +#include "video_core/renderer_vulkan/vk_device.h" +#include "video_core/renderer_vulkan/vk_pipeline_cache.h" +#include "video_core/renderer_vulkan/vk_update_descriptor.h" + +namespace Vulkan { + +void FillDescriptorUpdateTemplateEntries( + const VKDevice& device, const ShaderEntries& entries, u32& binding, u32& offset, + std::vector<vk::DescriptorUpdateTemplateEntry>& template_entries) { + static constexpr auto entry_size = static_cast<u32>(sizeof(DescriptorUpdateEntry)); + const auto AddEntry = [&](vk::DescriptorType descriptor_type, std::size_t count_) { + const u32 count = static_cast<u32>(count_); + if (descriptor_type == vk::DescriptorType::eUniformTexelBuffer && + device.GetDriverID() == vk::DriverIdKHR::eNvidiaProprietary) { + // Nvidia has a bug where updating multiple uniform texels at once causes the driver to + // crash. + for (u32 i = 0; i < count; ++i) { + template_entries.emplace_back(binding + i, 0, 1, descriptor_type, + offset + i * entry_size, entry_size); + } + } else if (count != 0) { + template_entries.emplace_back(binding, 0, count, descriptor_type, offset, entry_size); + } + offset += count * entry_size; + binding += count; + }; + + AddEntry(vk::DescriptorType::eUniformBuffer, entries.const_buffers.size()); + AddEntry(vk::DescriptorType::eStorageBuffer, entries.global_buffers.size()); + AddEntry(vk::DescriptorType::eUniformTexelBuffer, entries.texel_buffers.size()); + AddEntry(vk::DescriptorType::eCombinedImageSampler, entries.samplers.size()); + AddEntry(vk::DescriptorType::eStorageImage, entries.images.size()); +} + +} // namespace Vulkan |