mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
Add general purpose vulkan render cache
Takes in a general `vk::Format` rather than PICA-types
This commit is contained in:
parent
d4b75deaf8
commit
4b193c8d6b
2 changed files with 15 additions and 6 deletions
|
@ -83,8 +83,9 @@ class RendererVK final : public Renderer {
|
|||
std::vector<vk::UniqueImage> screenTexture = {};
|
||||
vk::UniqueDeviceMemory framebufferMemory = {};
|
||||
|
||||
std::map<u32, vk::UniqueRenderPass> renderPassCache;
|
||||
std::map<u64, vk::UniqueRenderPass> renderPassCache;
|
||||
|
||||
vk::RenderPass getRenderPass(vk::Format colorFormat, std::optional<vk::Format> depthFormat);
|
||||
vk::RenderPass getRenderPass(PICA::ColorFmt colorFormat, std::optional<PICA::DepthFmt> depthFormat);
|
||||
|
||||
// Recreate the swapchain, possibly re-using the old one in the case of a resize
|
||||
|
|
|
@ -151,11 +151,11 @@ RendererVK::Texture& RendererVK::getDepthRenderTexture(u32 addr, PICA::DepthFmt
|
|||
return newTexture;
|
||||
}
|
||||
|
||||
vk::RenderPass RendererVK::getRenderPass(PICA::ColorFmt colorFormat, std::optional<PICA::DepthFmt> depthFormat) {
|
||||
u32 renderPassHash = static_cast<u16>(colorFormat);
|
||||
vk::RenderPass RendererVK::getRenderPass(vk::Format colorFormat, std::optional<vk::Format> depthFormat) {
|
||||
u64 renderPassHash = static_cast<u32>(colorFormat);
|
||||
|
||||
if (depthFormat.has_value()) {
|
||||
renderPassHash |= (static_cast<u32>(depthFormat.value()) << 8);
|
||||
renderPassHash |= (static_cast<u64>(depthFormat.value()) << 32);
|
||||
}
|
||||
|
||||
// Cache hit
|
||||
|
@ -170,7 +170,7 @@ vk::RenderPass RendererVK::getRenderPass(PICA::ColorFmt colorFormat, std::option
|
|||
std::vector<vk::AttachmentDescription> renderPassAttachments = {};
|
||||
|
||||
vk::AttachmentDescription colorAttachment = {};
|
||||
colorAttachment.format = Vulkan::colorFormatToVulkan(colorFormat);
|
||||
colorAttachment.format = colorFormat;
|
||||
colorAttachment.samples = vk::SampleCountFlagBits::e1;
|
||||
colorAttachment.loadOp = vk::AttachmentLoadOp::eLoad;
|
||||
colorAttachment.storeOp = vk::AttachmentStoreOp::eStore;
|
||||
|
@ -182,7 +182,7 @@ vk::RenderPass RendererVK::getRenderPass(PICA::ColorFmt colorFormat, std::option
|
|||
|
||||
if (depthFormat.has_value()) {
|
||||
vk::AttachmentDescription depthAttachment = {};
|
||||
depthAttachment.format = Vulkan::depthFormatToVulkan(depthFormat.value());
|
||||
depthAttachment.format = depthFormat.value();
|
||||
depthAttachment.samples = vk::SampleCountFlagBits::e1;
|
||||
depthAttachment.loadOp = vk::AttachmentLoadOp::eLoad;
|
||||
depthAttachment.storeOp = vk::AttachmentStoreOp::eStore;
|
||||
|
@ -229,6 +229,14 @@ vk::RenderPass RendererVK::getRenderPass(PICA::ColorFmt colorFormat, std::option
|
|||
return {};
|
||||
}
|
||||
|
||||
vk::RenderPass RendererVK::getRenderPass(PICA::ColorFmt colorFormat, std::optional<PICA::DepthFmt> depthFormat) {
|
||||
if (depthFormat.has_value()) {
|
||||
return getRenderPass(Vulkan::colorFormatToVulkan(colorFormat), Vulkan::depthFormatToVulkan(depthFormat.value()));
|
||||
} else {
|
||||
return getRenderPass(Vulkan::colorFormatToVulkan(colorFormat), {});
|
||||
}
|
||||
}
|
||||
|
||||
vk::Result RendererVK::recreateSwapchain(vk::SurfaceKHR surface, vk::Extent2D swapchainExtent) {
|
||||
static constexpr u32 screenTextureWidth = 400; // Top screen is 400 pixels wide, bottom is 320
|
||||
static constexpr u32 screenTextureHeight = 2 * 240; // Both screens are 240 pixels tall
|
||||
|
|
Loading…
Add table
Reference in a new issue