Merge pull request #3425 from ReinUsesLisp/layered-framebuffer
texture_cache: Implement layered framebuffer attachments
This commit is contained in:
commit
e22ad52cdb
8 changed files with 74 additions and 51 deletions
|
@ -611,33 +611,34 @@ bool RasterizerVulkan::WalkAttachmentOverlaps(const CachedSurfaceView& attachmen
|
|||
std::tuple<vk::Framebuffer, vk::Extent2D> RasterizerVulkan::ConfigureFramebuffers(
|
||||
vk::RenderPass renderpass) {
|
||||
FramebufferCacheKey key{renderpass, std::numeric_limits<u32>::max(),
|
||||
std::numeric_limits<u32>::max()};
|
||||
std::numeric_limits<u32>::max(), std::numeric_limits<u32>::max()};
|
||||
|
||||
const auto MarkAsModifiedAndPush = [&](const View& view) {
|
||||
if (view == nullptr) {
|
||||
const auto try_push = [&](const View& view) {
|
||||
if (!view) {
|
||||
return false;
|
||||
}
|
||||
key.views.push_back(view->GetHandle());
|
||||
key.width = std::min(key.width, view->GetWidth());
|
||||
key.height = std::min(key.height, view->GetHeight());
|
||||
key.layers = std::min(key.layers, view->GetNumLayers());
|
||||
return true;
|
||||
};
|
||||
|
||||
for (std::size_t index = 0; index < std::size(color_attachments); ++index) {
|
||||
if (MarkAsModifiedAndPush(color_attachments[index])) {
|
||||
if (try_push(color_attachments[index])) {
|
||||
texture_cache.MarkColorBufferInUse(index);
|
||||
}
|
||||
}
|
||||
if (MarkAsModifiedAndPush(zeta_attachment)) {
|
||||
if (try_push(zeta_attachment)) {
|
||||
texture_cache.MarkDepthBufferInUse();
|
||||
}
|
||||
|
||||
const auto [fbentry, is_cache_miss] = framebuffer_cache.try_emplace(key);
|
||||
auto& framebuffer = fbentry->second;
|
||||
if (is_cache_miss) {
|
||||
const vk::FramebufferCreateInfo framebuffer_ci({}, key.renderpass,
|
||||
static_cast<u32>(key.views.size()),
|
||||
key.views.data(), key.width, key.height, 1);
|
||||
const vk::FramebufferCreateInfo framebuffer_ci(
|
||||
{}, key.renderpass, static_cast<u32>(key.views.size()), key.views.data(), key.width,
|
||||
key.height, key.layers);
|
||||
const auto dev = device.GetLogical();
|
||||
const auto& dld = device.GetDispatchLoader();
|
||||
framebuffer = dev.createFramebufferUnique(framebuffer_ci, nullptr, dld);
|
||||
|
|
|
@ -56,6 +56,7 @@ struct FramebufferCacheKey {
|
|||
vk::RenderPass renderpass{};
|
||||
u32 width = 0;
|
||||
u32 height = 0;
|
||||
u32 layers = 0;
|
||||
ImageViewsPack views;
|
||||
|
||||
std::size_t Hash() const noexcept {
|
||||
|
@ -66,12 +67,17 @@ struct FramebufferCacheKey {
|
|||
}
|
||||
boost::hash_combine(hash, width);
|
||||
boost::hash_combine(hash, height);
|
||||
boost::hash_combine(hash, layers);
|
||||
return hash;
|
||||
}
|
||||
|
||||
bool operator==(const FramebufferCacheKey& rhs) const noexcept {
|
||||
return std::tie(renderpass, views, width, height) ==
|
||||
std::tie(rhs.renderpass, rhs.views, rhs.width, rhs.height);
|
||||
return std::tie(renderpass, views, width, height, layers) ==
|
||||
std::tie(rhs.renderpass, rhs.views, rhs.width, rhs.height, rhs.layers);
|
||||
}
|
||||
|
||||
bool operator!=(const FramebufferCacheKey& rhs) const noexcept {
|
||||
return !operator==(rhs);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -151,6 +151,10 @@ public:
|
|||
return params.GetMipHeight(base_level);
|
||||
}
|
||||
|
||||
u32 GetNumLayers() const {
|
||||
return num_layers;
|
||||
}
|
||||
|
||||
bool IsBufferView() const {
|
||||
return buffer_view;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue