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