summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan/vk_blit_screen.h
blob: 531c57fc5c49bd973aa54e688c496156ac904384 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <list>
#include <memory>

#include "core/frontend/framebuffer_layout.h"
#include "video_core/host1x/gpu_device_memory_manager.h"
#include "video_core/renderer_vulkan/present/layer.h"
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"

namespace Core {
class System;
}

struct PresentFilters;

namespace Tegra {
struct FramebufferConfig;
}

namespace Settings {
enum class ScalingFilter : u32;
} // namespace Settings

namespace Vulkan {

class Device;
class RasterizerVulkan;
class Scheduler;
class PresentManager;
class WindowAdaptPass;

struct Frame;

struct FramebufferTextureInfo {
    VkImage image{};
    VkImageView image_view{};
    u32 width{};
    u32 height{};
    u32 scaled_width{};
    u32 scaled_height{};
};

class BlitScreen {
public:
    explicit BlitScreen(Tegra::MaxwellDeviceMemoryManager& device_memory, const Device& device,
                        MemoryAllocator& memory_allocator, PresentManager& present_manager,
                        Scheduler& scheduler, const PresentFilters& filters);
    ~BlitScreen();

    void DrawToFrame(RasterizerVulkan& rasterizer, Frame* frame,
                     std::span<const Tegra::FramebufferConfig> framebuffers,
                     const Layout::FramebufferLayout& layout, size_t current_swapchain_image_count,
                     VkFormat current_swapchain_view_format);

    [[nodiscard]] vk::Framebuffer CreateFramebuffer(const Layout::FramebufferLayout& layout,
                                                    VkImageView image_view,
                                                    VkFormat current_view_format);

private:
    void WaitIdle();
    void SetWindowAdaptPass();
    vk::Framebuffer CreateFramebuffer(const VkImageView& image_view, VkExtent2D extent,
                                      VkRenderPass render_pass);

    Tegra::MaxwellDeviceMemoryManager& device_memory;
    const Device& device;
    MemoryAllocator& memory_allocator;
    PresentManager& present_manager;
    Scheduler& scheduler;
    const PresentFilters& filters;
    std::size_t image_count{};
    std::size_t image_index{};
    VkFormat swapchain_view_format{};

    Settings::ScalingFilter scaling_filter{};
    std::unique_ptr<WindowAdaptPass> window_adapt{};
    std::list<Layer> layers{};
};

} // namespace Vulkan