vk_pipeline_cache: Add file and define descriptor update template filler
This function allows us to share code between compute and graphics pipelines compilation.
This commit is contained in:
parent
3142f1b597
commit
b392a5986e
|
@ -163,6 +163,8 @@ if (ENABLE_VULKAN)
|
||||||
renderer_vulkan/vk_image.h
|
renderer_vulkan/vk_image.h
|
||||||
renderer_vulkan/vk_memory_manager.cpp
|
renderer_vulkan/vk_memory_manager.cpp
|
||||||
renderer_vulkan/vk_memory_manager.h
|
renderer_vulkan/vk_memory_manager.h
|
||||||
|
renderer_vulkan/vk_pipeline_cache.cpp
|
||||||
|
renderer_vulkan/vk_pipeline_cache.h
|
||||||
renderer_vulkan/vk_rasterizer.h
|
renderer_vulkan/vk_rasterizer.h
|
||||||
renderer_vulkan/vk_renderpass_cache.cpp
|
renderer_vulkan/vk_renderpass_cache.cpp
|
||||||
renderer_vulkan/vk_renderpass_cache.h
|
renderer_vulkan/vk_renderpass_cache.h
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2019 yuzu Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
#include "video_core/renderer_vulkan/declarations.h"
|
||||||
|
#include "video_core/renderer_vulkan/vk_shader_decompiler.h"
|
||||||
|
#include "video_core/shader/shader_ir.h"
|
||||||
|
|
||||||
|
namespace Vulkan {
|
||||||
|
|
||||||
|
class VKDevice;
|
||||||
|
|
||||||
|
void FillDescriptorUpdateTemplateEntries(
|
||||||
|
const VKDevice& device, const ShaderEntries& entries, u32& binding, u32& offset,
|
||||||
|
std::vector<vk::DescriptorUpdateTemplateEntry>& template_entries);
|
||||||
|
|
||||||
|
} // namespace Vulkan
|
Reference in New Issue