blob: 9f8704fe152d3307f5e36c5328cb22a454ac1a91 (
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
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// NVIDIA DLSS (through NVIDIA Streamline) in place of a game's DLSS
// evaluation. NVIDIA's DLLs come from the user's PC; see vulkan_common/streamline.h.
#pragma once
#include <array>
#include <atomic>
#include "common/common_types.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"
namespace Vulkan {
class Device;
class MemoryAllocator;
class Scheduler;
class StreamlineDlssUpscaler {
public:
struct Image {
VkImageView view;
VkImage image;
VkFormat format;
VkImageSubresourceRange range; ///< The view's level and layer, with the view's aspect.
VkImageAspectFlags barrier_aspect; ///< Every aspect of the image's format.
};
struct Inputs {
Image color; ///< Jittered linear colour at the render size.
Image depth; ///< Device depth (reversed) at the render size.
Image motion_vectors; ///< Motion to the previous frame at the render size.
VkExtent2D render_size;
VkExtent2D upscale_size;
/// This frame's sample offset in render pixels, as the game hands its own DLSS.
std::array<f32, 2> jitter;
/// Turns a motion vector into render pixels (the render size for UV offsets).
std::array<f32, 2> motion_vector_scale;
bool reset;
};
/// Throws vk::Exception when Streamline has no DLSS for this device.
explicit StreamlineDlssUpscaler(const Device& device, Scheduler& scheduler,
MemoryAllocator& memory_allocator);
~StreamlineDlssUpscaler();
/// Records one evaluation into the output image (RGBA16F at the upscale size, GENERAL
/// layout). Returns false when DLSS can't run, so the caller can fall back to FSR 3.1.
bool Upscale(const Inputs& inputs);
[[nodiscard]] VkImage OutputImage() const noexcept {
return *output_image;
}
[[nodiscard]] VkImageView OutputView() const noexcept {
return *output_view;
}
/// Nearest-neighbour clamp sampler (normalized coordinates), for reading the output.
[[nodiscard]] VkSampler PointSampler() const noexcept {
return *point_sampler;
}
private:
void CreateOutput(VkExtent2D upscale_size);
const Device& device;
Scheduler& scheduler;
MemoryAllocator& memory_allocator;
void* set_options{}; ///< slDLSSSetOptions
VkExtent2D render_extent{};
VkExtent2D upscale_extent{};
u32 frame_index{};
vk::Image output_image;
vk::ImageView output_view;
vk::Sampler point_sampler;
std::atomic<bool> failed{};
};
} // namespace Vulkan
|