Merge branch 'postprocessing'

This commit is contained in:
Connor McLaughlin
2020-09-13 12:14:21 +10:00
54 changed files with 2894 additions and 612 deletions

View File

@ -1,5 +1,6 @@
#pragma once
#include "common/vulkan/staging_texture.h"
#include "common/vulkan/stream_buffer.h"
#include "common/vulkan/swap_chain.h"
#include "common/window_info.h"
#include "core/host_display.h"
@ -12,6 +13,10 @@ class StreamBuffer;
class SwapChain;
} // namespace Vulkan
#ifndef LIBRETRO
#include "postprocessing_chain.h"
#endif
namespace FrontendCommon {
class VulkanHostDisplay : public HostDisplay
@ -38,6 +43,8 @@ public:
virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override;
virtual void DestroyRenderSurface() override;
virtual bool SetPostProcessingChain(const std::string_view& config) override;
std::unique_ptr<HostDisplayTexture> CreateTexture(u32 width, u32 height, const void* initial_data,
u32 initial_data_stride, bool dynamic) override;
void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* texture_data,
@ -60,6 +67,25 @@ protected:
float src_rect_height;
};
#ifndef LIBRETRO
struct PostProcessingStage
{
PostProcessingStage() = default;
PostProcessingStage(PostProcessingStage&& move);
~PostProcessingStage();
VkPipeline pipeline = VK_NULL_HANDLE;
VkFramebuffer output_framebuffer = VK_NULL_HANDLE;
Vulkan::Texture output_texture;
u32 uniforms_size = 0;
};
bool CheckPostProcessingRenderTargets(u32 target_width, u32 target_height);
void ApplyPostProcessingChain(s32 final_left, s32 final_top, s32 final_width, s32 final_height, void* texture_handle,
u32 texture_width, s32 texture_height, s32 texture_view_x, s32 texture_view_y,
s32 texture_view_width, s32 texture_view_height);
#endif
// Can be overridden by frontends.
virtual VkRenderPass GetRenderPassForDisplay() const;
@ -69,6 +95,7 @@ protected:
virtual bool CreateImGuiContext();
virtual void DestroyImGuiContext();
void BeginSwapChainRenderPass(VkFramebuffer framebuffer);
void RenderDisplay();
void RenderImGui();
void RenderSoftwareCursor();
@ -89,6 +116,19 @@ protected:
Vulkan::StagingTexture m_upload_staging_texture;
Vulkan::StagingTexture m_readback_staging_texture;
#ifndef LIBRETRO
VkDescriptorSetLayout m_post_process_descriptor_set_layout = VK_NULL_HANDLE;
VkDescriptorSetLayout m_post_process_ubo_descriptor_set_layout = VK_NULL_HANDLE;
VkPipelineLayout m_post_process_pipeline_layout = VK_NULL_HANDLE;
VkPipelineLayout m_post_process_ubo_pipeline_layout = VK_NULL_HANDLE;
PostProcessingChain m_post_processing_chain;
Vulkan::Texture m_post_processing_input_texture;
VkFramebuffer m_post_processing_input_framebuffer = VK_NULL_HANDLE;
Vulkan::StreamBuffer m_post_processing_ubo;
std::vector<PostProcessingStage> m_post_processing_stages;
#endif
};
} // namespace FrontendCommon