Debian Codegraph @

Source/Core/VideoBackends/Vulkan/Constants.h

raw symbols SCIP
1 // Copyright 2016 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <cstddef>
7
8 #include "Common/BitField.h"
9 #include "Common/CommonTypes.h"
10 #include "VideoBackends/Vulkan/VulkanLoader.h"
11
12 namespace Vulkan
13 {
14 // Number of command buffers.
15 constexpr size_t NUM_COMMAND_BUFFERS = 8;
16
17 // Number of frames in flight, will be used to decide how many descriptor pools are used
18 constexpr size_t NUM_FRAMES_IN_FLIGHT = 2;
19
20 // Staging buffer usage - optimize for uploads or readbacks
21 enum STAGING_BUFFER_TYPE
22 {
23 STAGING_BUFFER_TYPE_UPLOAD,
24 STAGING_BUFFER_TYPE_READBACK
25 };
26
27 // Descriptor set layouts
28 enum DESCRIPTOR_SET_LAYOUT
29 {
30 DESCRIPTOR_SET_LAYOUT_STANDARD_UNIFORM_BUFFERS,
31 DESCRIPTOR_SET_LAYOUT_STANDARD_SAMPLERS,
32 DESCRIPTOR_SET_LAYOUT_STANDARD_SHADER_STORAGE_BUFFERS,
33 DESCRIPTOR_SET_LAYOUT_UTILITY_UNIFORM_BUFFER,
34 DESCRIPTOR_SET_LAYOUT_UTILITY_SAMPLERS,
35 DESCRIPTOR_SET_LAYOUT_COMPUTE,
36 NUM_DESCRIPTOR_SET_LAYOUTS
37 };
38
39 // We use four pipeline layouts:
40 // - Standard
41 // - Per-stage UBO (VS/GS/PS, VS constants accessible from PS) [set=0, binding=0-3]
42 // - 8 combined image samplers (accessible from PS) [set=1, binding=0-7]
43 // - 1 SSBO accessible from PS if supported [set=2, binding=0]
44 // - Uber
45 // - Like standard, plus 1 SSBO accessible from VS if supported [set=2, binding=1]
46 // - Utility
47 // - 1 combined UBO, accessible from VS/GS/PS [set=0, binding=0]
48 // - 8 combined image samplers (accessible from PS) [set=1, binding=0-7]
49 // - 1 texel buffer (accessible from PS) [set=1, binding=8]
50 // - Compute
51 // - 1 uniform buffer [set=0, binding=0]
52 // - 8 combined image samplers [set=0, binding=1-8]
53 // - 2 texel buffers [set=0, binding=9-10]
54 // - 8 storage image [set=0, binding=11-18]
55 //
56 // All four pipeline layout share the first two descriptor sets (uniform buffers, PS samplers).
57 // The third descriptor set (see bind points above) is used for storage or texel buffers.
58 //
59 enum PIPELINE_LAYOUT
60 {
61 PIPELINE_LAYOUT_STANDARD,
62 PIPELINE_LAYOUT_UBER,
63 PIPELINE_LAYOUT_UTILITY,
64 PIPELINE_LAYOUT_COMPUTE,
65 NUM_PIPELINE_LAYOUTS
66 };
67
68 // Uniform buffer bindings within the first descriptor set
69 enum UNIFORM_BUFFER_DESCRIPTOR_SET_BINDING
70 {
71 UBO_DESCRIPTOR_SET_BINDING_PS,
72 UBO_DESCRIPTOR_SET_BINDING_VS,
73 UBO_DESCRIPTOR_SET_BINDING_CUST,
74 UBO_DESCRIPTOR_SET_BINDING_GS,
75 NUM_UBO_DESCRIPTOR_SET_BINDINGS
76 };
77
78 // Maximum number of attributes per vertex (we don't have any more than this?)
79 constexpr u32 MAX_VERTEX_ATTRIBUTES = 16;
80
81 // Number of pixel shader texture slots
82 constexpr u32 NUM_UTILITY_PIXEL_SAMPLERS = 8;
83
84 // Number of texel buffer binding points.
85 constexpr u32 NUM_COMPUTE_TEXEL_BUFFERS = 2;
86
87 // Textures that don't fit into this buffer will be uploaded with a separate buffer (see below).
88 constexpr u32 TEXTURE_UPLOAD_BUFFER_SIZE = 32 * 1024 * 1024;
89
90 // Textures greater than 1024*1024 will be put in staging textures that are released after
91 // execution instead. A 2048x2048 texture is 16MB, and we'd only fit four of these in our
92 // streaming buffer and be blocking frequently. Games are unlikely to have textures this
93 // large anyway, so it's only really an issue for HD texture packs, and memory is not
94 // a limiting factor in these scenarios anyway.
95 constexpr u32 STAGING_TEXTURE_UPLOAD_THRESHOLD = 1024 * 1024 * 4;
96 } // namespace Vulkan