2016-08-13 12:57:50 +00:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-10-01 03:07:50 +00:00
|
|
|
#include <cstddef>
|
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
#include "Common/BitField.h"
|
2016-10-01 03:07:50 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2016-08-13 12:57:50 +00:00
|
|
|
#include "VideoBackends/Vulkan/VulkanLoader.h"
|
|
|
|
|
|
|
|
namespace Vulkan
|
|
|
|
{
|
2022-09-30 23:17:38 +00:00
|
|
|
// Number of command buffers.
|
2022-09-30 23:24:54 +00:00
|
|
|
constexpr size_t NUM_COMMAND_BUFFERS = 8;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
2022-09-30 23:17:38 +00:00
|
|
|
// Number of frames in flight, will be used to decide how many descriptor pools are used
|
|
|
|
constexpr size_t NUM_FRAMES_IN_FLIGHT = 2;
|
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
// Staging buffer usage - optimize for uploads or readbacks
|
|
|
|
enum STAGING_BUFFER_TYPE
|
|
|
|
{
|
|
|
|
STAGING_BUFFER_TYPE_UPLOAD,
|
|
|
|
STAGING_BUFFER_TYPE_READBACK
|
|
|
|
};
|
|
|
|
|
2016-11-13 05:38:32 +00:00
|
|
|
// Descriptor set layouts
|
|
|
|
enum DESCRIPTOR_SET_LAYOUT
|
2016-08-13 12:57:50 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
DESCRIPTOR_SET_LAYOUT_STANDARD_UNIFORM_BUFFERS,
|
|
|
|
DESCRIPTOR_SET_LAYOUT_STANDARD_SAMPLERS,
|
|
|
|
DESCRIPTOR_SET_LAYOUT_STANDARD_SHADER_STORAGE_BUFFERS,
|
|
|
|
DESCRIPTOR_SET_LAYOUT_UTILITY_UNIFORM_BUFFER,
|
|
|
|
DESCRIPTOR_SET_LAYOUT_UTILITY_SAMPLERS,
|
2016-12-09 12:23:04 +00:00
|
|
|
DESCRIPTOR_SET_LAYOUT_COMPUTE,
|
2016-11-13 05:38:32 +00:00
|
|
|
NUM_DESCRIPTOR_SET_LAYOUTS
|
|
|
|
};
|
|
|
|
|
2016-11-13 05:24:55 +00:00
|
|
|
// We use four pipeline layouts:
|
|
|
|
// - Standard
|
2023-09-20 00:29:38 +00:00
|
|
|
// - Per-stage UBO (VS/GS/PS, VS constants accessible from PS) [set=0, binding=0-3]
|
2019-02-15 01:59:50 +00:00
|
|
|
// - 8 combined image samplers (accessible from PS) [set=1, binding=0-7]
|
|
|
|
// - 1 SSBO accessible from PS if supported [set=2, binding=0]
|
2022-06-19 03:49:03 +00:00
|
|
|
// - Uber
|
|
|
|
// - Like standard, plus 1 SSBO accessible from VS if supported [set=2, binding=1]
|
2019-02-15 01:59:50 +00:00
|
|
|
// - Utility
|
|
|
|
// - 1 combined UBO, accessible from VS/GS/PS [set=0, binding=0]
|
|
|
|
// - 8 combined image samplers (accessible from PS) [set=1, binding=0-7]
|
|
|
|
// - 1 texel buffer (accessible from PS) [set=1, binding=8]
|
2016-12-09 12:23:04 +00:00
|
|
|
// - Compute
|
|
|
|
// - 1 uniform buffer [set=0, binding=0]
|
2023-06-10 17:35:36 +00:00
|
|
|
// - 8 combined image samplers [set=0, binding=1-8]
|
|
|
|
// - 2 texel buffers [set=0, binding=9-10]
|
|
|
|
// - 8 storage image [set=0, binding=11-18]
|
2016-11-13 05:24:55 +00:00
|
|
|
//
|
|
|
|
// All four pipeline layout share the first two descriptor sets (uniform buffers, PS samplers).
|
|
|
|
// The third descriptor set (see bind points above) is used for storage or texel buffers.
|
|
|
|
//
|
|
|
|
enum PIPELINE_LAYOUT
|
|
|
|
{
|
|
|
|
PIPELINE_LAYOUT_STANDARD,
|
2022-06-19 03:49:03 +00:00
|
|
|
PIPELINE_LAYOUT_UBER,
|
2017-09-08 09:42:56 +00:00
|
|
|
PIPELINE_LAYOUT_UTILITY,
|
2016-12-09 12:23:04 +00:00
|
|
|
PIPELINE_LAYOUT_COMPUTE,
|
2016-11-13 05:24:55 +00:00
|
|
|
NUM_PIPELINE_LAYOUTS
|
|
|
|
};
|
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
// Uniform buffer bindings within the first descriptor set
|
|
|
|
enum UNIFORM_BUFFER_DESCRIPTOR_SET_BINDING
|
|
|
|
{
|
|
|
|
UBO_DESCRIPTOR_SET_BINDING_PS,
|
|
|
|
UBO_DESCRIPTOR_SET_BINDING_VS,
|
2023-09-20 00:29:38 +00:00
|
|
|
UBO_DESCRIPTOR_SET_BINDING_PS_CUST,
|
2016-08-13 12:57:50 +00:00
|
|
|
UBO_DESCRIPTOR_SET_BINDING_GS,
|
|
|
|
NUM_UBO_DESCRIPTOR_SET_BINDINGS
|
|
|
|
};
|
|
|
|
|
|
|
|
// Maximum number of attributes per vertex (we don't have any more than this?)
|
2019-02-15 01:59:50 +00:00
|
|
|
constexpr u32 MAX_VERTEX_ATTRIBUTES = 16;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
// Number of pixel shader texture slots
|
2023-02-10 06:28:06 +00:00
|
|
|
constexpr u32 NUM_UTILITY_PIXEL_SAMPLERS = 8;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
// Number of texel buffer binding points.
|
|
|
|
constexpr u32 NUM_COMPUTE_TEXEL_BUFFERS = 2;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
// Textures that don't fit into this buffer will be uploaded with a separate buffer (see below).
|
2019-02-15 01:59:50 +00:00
|
|
|
constexpr u32 TEXTURE_UPLOAD_BUFFER_SIZE = 32 * 1024 * 1024;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
// Textures greater than 1024*1024 will be put in staging textures that are released after
|
|
|
|
// execution instead. A 2048x2048 texture is 16MB, and we'd only fit four of these in our
|
|
|
|
// streaming buffer and be blocking frequently. Games are unlikely to have textures this
|
|
|
|
// large anyway, so it's only really an issue for HD texture packs, and memory is not
|
|
|
|
// a limiting factor in these scenarios anyway.
|
2019-02-15 01:59:50 +00:00
|
|
|
constexpr u32 STAGING_TEXTURE_UPLOAD_THRESHOLD = 1024 * 1024 * 4;
|
2016-08-13 12:57:50 +00:00
|
|
|
} // namespace Vulkan
|