Dynamic rendering is a Vulkan 1.3 feature. Most platforms have support for them, but there are several legacy platforms that don't support dynamic rendering or have driver bugs that don't allow us to use it. This change will make dynamic rendering optional allowing legacy platforms to use Vulkan. **Limitations** `GPU_LOADACTION_CLEAR` is implemented as clear attachments. Render passes do support load clear, but adding support to it would add complexity as it required multiple pipeline variations to support suspend/resume rendering. It isn't clear when which variation should be used what lead to compiling to many pipelines and branches in the codebase. Using clear attachments doesn't require the complexity for what is expected to be only used by platforms not supported by the GPU vendors. Subpass inputs and dual source blending are not supported as Subpass inputs can alter the exact binding location of attachments. Fixing this would add code complexity that is not used. Ref: #129063 **Current state**  Pull Request: https://projects.blender.org/blender/blender/pulls/129062
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_vector.hh"
|
|
|
|
#include "vk_descriptor_set.hh"
|
|
|
|
namespace blender::gpu {
|
|
class VKDevice;
|
|
|
|
/**
|
|
* List of VkDescriptorPools.
|
|
*
|
|
* In Vulkan a pool is constructed with a fixed size per resource type. When more resources are
|
|
* needed it a next pool should be created. VKDescriptorPools will keep track of those pools and
|
|
* construct new pools when the previous one is exhausted.
|
|
*
|
|
* At the beginning of a new frame the descriptor pools are reset. This will start allocating
|
|
* again from the first descriptor pool in order to use freed space from previous pools.
|
|
*/
|
|
class VKDescriptorPools {
|
|
/**
|
|
* Pool sizes to use. When one descriptor pool is requested to allocate a descriptor but isn't
|
|
* able to do so, it will fail.
|
|
*
|
|
* Better defaults should be set later on, when we know more about our resource usage.
|
|
*/
|
|
static constexpr uint32_t POOL_SIZE_STORAGE_BUFFER = 1000;
|
|
static constexpr uint32_t POOL_SIZE_DESCRIPTOR_SETS = 1000;
|
|
static constexpr uint32_t POOL_SIZE_STORAGE_IMAGE = 1000;
|
|
static constexpr uint32_t POOL_SIZE_COMBINED_IMAGE_SAMPLER = 1000;
|
|
static constexpr uint32_t POOL_SIZE_UNIFORM_BUFFER = 1000;
|
|
static constexpr uint32_t POOL_SIZE_UNIFORM_TEXEL_BUFFER = 1000;
|
|
static constexpr uint32_t POOL_SIZE_INPUT_ATTACHMENT = 1000;
|
|
|
|
Vector<VkDescriptorPool> pools_;
|
|
int64_t active_pool_index_ = 0;
|
|
|
|
public:
|
|
VKDescriptorPools();
|
|
~VKDescriptorPools();
|
|
|
|
void init(const VKDevice &vk_device);
|
|
|
|
VkDescriptorSet allocate(const VkDescriptorSetLayout descriptor_set_layout);
|
|
|
|
/**
|
|
* Reset the pools to start looking for free space from the first descriptor pool.
|
|
*/
|
|
void reset();
|
|
|
|
private:
|
|
VkDescriptorPool active_pool_get();
|
|
void activate_next_pool();
|
|
void activate_last_pool();
|
|
bool is_last_pool_active();
|
|
void add_new_pool(const VKDevice &device);
|
|
};
|
|
} // namespace blender::gpu
|