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
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <utility>
#include "common/assert.h"
#include "video_core/textures/texture.h"
namespace VideoCommon {
[[nodiscard]] inline std::pair<int, int> SamplesLog2(int num_samples) {
switch (num_samples) {
case 1:
return {0, 0};
case 2:
return {1, 0};
case 4:
return {1, 1};
case 8:
return {2, 1};
case 16:
return {2, 2};
}
ASSERT_MSG(false, "Invalid number of samples={}", num_samples);
return {0, 0};
}
[[nodiscard]] inline int NumSamples(Tegra::Texture::MsaaMode msaa_mode) {
using Tegra::Texture::MsaaMode;
switch (msaa_mode) {
case MsaaMode::Msaa1x1:
return 1;
case MsaaMode::Msaa2x1:
case MsaaMode::Msaa2x1_D3D:
return 2;
case MsaaMode::Msaa2x2:
case MsaaMode::Msaa2x2_VC4:
case MsaaMode::Msaa2x2_VC12:
return 4;
case MsaaMode::Msaa4x2:
case MsaaMode::Msaa4x2_D3D:
case MsaaMode::Msaa4x2_VC8:
case MsaaMode::Msaa4x2_VC24:
return 8;
case MsaaMode::Msaa4x4:
return 16;
}
ASSERT_MSG(false, "Invalid MSAA mode={}", static_cast<int>(msaa_mode));
return 1;
}
[[nodiscard]] inline int NumSamplesX(Tegra::Texture::MsaaMode msaa_mode) {
using Tegra::Texture::MsaaMode;
switch (msaa_mode) {
case MsaaMode::Msaa1x1:
return 1;
case MsaaMode::Msaa2x1:
case MsaaMode::Msaa2x1_D3D:
case MsaaMode::Msaa2x2:
case MsaaMode::Msaa2x2_VC4:
case MsaaMode::Msaa2x2_VC12:
return 2;
case MsaaMode::Msaa4x2:
case MsaaMode::Msaa4x2_D3D:
case MsaaMode::Msaa4x2_VC8:
case MsaaMode::Msaa4x2_VC24:
case MsaaMode::Msaa4x4:
return 4;
}
ASSERT_MSG(false, "Invalid MSAA mode={}", static_cast<int>(msaa_mode));
return 1;
}
[[nodiscard]] inline int NumSamplesY(Tegra::Texture::MsaaMode msaa_mode) {
using Tegra::Texture::MsaaMode;
switch (msaa_mode) {
case MsaaMode::Msaa1x1:
case MsaaMode::Msaa2x1:
case MsaaMode::Msaa2x1_D3D:
return 1;
case MsaaMode::Msaa2x2:
case MsaaMode::Msaa2x2_VC4:
case MsaaMode::Msaa2x2_VC12:
case MsaaMode::Msaa4x2:
case MsaaMode::Msaa4x2_D3D:
case MsaaMode::Msaa4x2_VC8:
case MsaaMode::Msaa4x2_VC24:
return 2;
case MsaaMode::Msaa4x4:
return 4;
}
ASSERT_MSG(false, "Invalid MSAA mode={}", static_cast<int>(msaa_mode));
return 1;
}
} // namespace VideoCommon
|