summaryrefslogtreecommitdiff
path: root/src/video_core/surface.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2020-07-21 00:13:04 -0400
committerGravatar GitHub2020-07-21 00:13:04 -0400
commit3d13d7f48f3bf7c1fb7b7673e963aa3e54db2838 (patch)
tree3214c882ce18526a3e57223ae96f06e7083369f2 /src/video_core/surface.cpp
parentMerge pull request #4168 from ReinUsesLisp/global-memory (diff)
parentvideo_core: Rearrange pixel format names (diff)
downloadyuzu-3d13d7f48f3bf7c1fb7b7673e963aa3e54db2838.tar.gz
yuzu-3d13d7f48f3bf7c1fb7b7673e963aa3e54db2838.tar.xz
yuzu-3d13d7f48f3bf7c1fb7b7673e963aa3e54db2838.zip
Merge pull request #4324 from ReinUsesLisp/formats
video_core: Fix, add and rename pixel formats
Diffstat (limited to 'src/video_core/surface.cpp')
-rw-r--r--src/video_core/surface.cpp257
1 files changed, 125 insertions, 132 deletions
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index bbe93903c..1688267bb 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -74,117 +74,131 @@ bool SurfaceTargetIsArray(SurfaceTarget target) {
74 74
75PixelFormat PixelFormatFromDepthFormat(Tegra::DepthFormat format) { 75PixelFormat PixelFormatFromDepthFormat(Tegra::DepthFormat format) {
76 switch (format) { 76 switch (format) {
77 case Tegra::DepthFormat::S8_Z24_UNORM: 77 case Tegra::DepthFormat::S8_UINT_Z24_UNORM:
78 return PixelFormat::S8Z24; 78 return PixelFormat::S8_UINT_D24_UNORM;
79 case Tegra::DepthFormat::Z24_S8_UNORM: 79 case Tegra::DepthFormat::D24S8_UNORM:
80 return PixelFormat::Z24S8; 80 return PixelFormat::D24_UNORM_S8_UINT;
81 case Tegra::DepthFormat::Z32_FLOAT: 81 case Tegra::DepthFormat::D32_FLOAT:
82 return PixelFormat::Z32F; 82 return PixelFormat::D32_FLOAT;
83 case Tegra::DepthFormat::Z16_UNORM: 83 case Tegra::DepthFormat::D16_UNORM:
84 return PixelFormat::Z16; 84 return PixelFormat::D16_UNORM;
85 case Tegra::DepthFormat::Z32_S8_X24_FLOAT: 85 case Tegra::DepthFormat::D32_FLOAT_S8X24_UINT:
86 return PixelFormat::Z32FS8; 86 return PixelFormat::D32_FLOAT_S8_UINT;
87 default: 87 default:
88 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 88 UNIMPLEMENTED_MSG("Unimplemented format={}", static_cast<u32>(format));
89 UNREACHABLE(); 89 return PixelFormat::S8_UINT_D24_UNORM;
90 return PixelFormat::S8Z24;
91 } 90 }
92} 91}
93 92
94PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) { 93PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) {
95 switch (format) { 94 switch (format) {
96 case Tegra::RenderTargetFormat::RGBA8_SRGB: 95 case Tegra::RenderTargetFormat::R32B32G32A32_FLOAT:
97 return PixelFormat::RGBA8_SRGB; 96 return PixelFormat::R32G32B32A32_FLOAT;
98 case Tegra::RenderTargetFormat::RGBA8_UNORM: 97 case Tegra::RenderTargetFormat::R32G32B32A32_SINT:
99 return PixelFormat::ABGR8U; 98 return PixelFormat::R32G32B32A32_SINT;
100 case Tegra::RenderTargetFormat::RGBA8_SNORM: 99 case Tegra::RenderTargetFormat::R32G32B32A32_UINT:
101 return PixelFormat::ABGR8S; 100 return PixelFormat::R32G32B32A32_UINT;
102 case Tegra::RenderTargetFormat::RGBA8_UINT: 101 case Tegra::RenderTargetFormat::R16G16B16A16_UNORM:
103 return PixelFormat::ABGR8UI; 102 return PixelFormat::R16G16B16A16_UNORM;
104 case Tegra::RenderTargetFormat::BGRA8_SRGB: 103 case Tegra::RenderTargetFormat::R16G16B16A16_SNORM:
105 return PixelFormat::BGRA8_SRGB; 104 return PixelFormat::R16G16B16A16_SNORM;
106 case Tegra::RenderTargetFormat::BGRA8_UNORM: 105 case Tegra::RenderTargetFormat::R16G16B16A16_SINT:
107 return PixelFormat::BGRA8; 106 return PixelFormat::R16G16B16A16_SINT;
108 case Tegra::RenderTargetFormat::RGB10_A2_UNORM: 107 case Tegra::RenderTargetFormat::R16G16B16A16_UINT:
109 return PixelFormat::A2B10G10R10U; 108 return PixelFormat::R16G16B16A16_UINT;
110 case Tegra::RenderTargetFormat::RGBA16_FLOAT: 109 case Tegra::RenderTargetFormat::R16G16B16A16_FLOAT:
111 return PixelFormat::RGBA16F; 110 return PixelFormat::R16G16B16A16_FLOAT;
112 case Tegra::RenderTargetFormat::RGBA16_UNORM: 111 case Tegra::RenderTargetFormat::R32G32_FLOAT:
113 return PixelFormat::RGBA16U; 112 return PixelFormat::R32G32_FLOAT;
114 case Tegra::RenderTargetFormat::RGBA16_SNORM: 113 case Tegra::RenderTargetFormat::R32G32_SINT:
115 return PixelFormat::RGBA16S; 114 return PixelFormat::R32G32_SINT;
116 case Tegra::RenderTargetFormat::RGBA16_UINT: 115 case Tegra::RenderTargetFormat::R32G32_UINT:
117 return PixelFormat::RGBA16UI; 116 return PixelFormat::R32G32_UINT;
118 case Tegra::RenderTargetFormat::RGBA32_FLOAT: 117 case Tegra::RenderTargetFormat::R16G16B16X16_FLOAT:
119 return PixelFormat::RGBA32F; 118 return PixelFormat::R16G16B16X16_FLOAT;
120 case Tegra::RenderTargetFormat::RG32_FLOAT: 119 case Tegra::RenderTargetFormat::B8G8R8A8_UNORM:
121 return PixelFormat::RG32F; 120 return PixelFormat::B8G8R8A8_UNORM;
122 case Tegra::RenderTargetFormat::R11G11B10_FLOAT: 121 case Tegra::RenderTargetFormat::B8G8R8A8_SRGB:
123 return PixelFormat::R11FG11FB10F; 122 return PixelFormat::B8G8R8A8_SRGB;
124 case Tegra::RenderTargetFormat::B5G6R5_UNORM: 123 case Tegra::RenderTargetFormat::A2B10G10R10_UNORM:
125 return PixelFormat::B5G6R5U; 124 return PixelFormat::A2B10G10R10_UNORM;
126 case Tegra::RenderTargetFormat::BGR5A1_UNORM: 125 case Tegra::RenderTargetFormat::A2B10G10R10_UINT:
127 return PixelFormat::A1B5G5R5U; 126 return PixelFormat::A2B10G10R10_UINT;
128 case Tegra::RenderTargetFormat::RGBA32_UINT: 127 case Tegra::RenderTargetFormat::A8B8G8R8_UNORM:
129 return PixelFormat::RGBA32UI; 128 return PixelFormat::A8B8G8R8_UNORM;
130 case Tegra::RenderTargetFormat::R8_UNORM: 129 case Tegra::RenderTargetFormat::A8B8G8R8_SRGB:
131 return PixelFormat::R8U; 130 return PixelFormat::A8B8G8R8_SRGB;
132 case Tegra::RenderTargetFormat::R8_UINT: 131 case Tegra::RenderTargetFormat::A8B8G8R8_SNORM:
133 return PixelFormat::R8UI; 132 return PixelFormat::A8B8G8R8_SNORM;
134 case Tegra::RenderTargetFormat::RG16_FLOAT: 133 case Tegra::RenderTargetFormat::A8B8G8R8_SINT:
135 return PixelFormat::RG16F; 134 return PixelFormat::A8B8G8R8_SINT;
136 case Tegra::RenderTargetFormat::RG16_UINT: 135 case Tegra::RenderTargetFormat::A8B8G8R8_UINT:
137 return PixelFormat::RG16UI; 136 return PixelFormat::A8B8G8R8_UINT;
138 case Tegra::RenderTargetFormat::RG16_SINT: 137 case Tegra::RenderTargetFormat::R16G16_UNORM:
139 return PixelFormat::RG16I; 138 return PixelFormat::R16G16_UNORM;
140 case Tegra::RenderTargetFormat::RG16_UNORM: 139 case Tegra::RenderTargetFormat::R16G16_SNORM:
141 return PixelFormat::RG16; 140 return PixelFormat::R16G16_SNORM;
142 case Tegra::RenderTargetFormat::RG16_SNORM: 141 case Tegra::RenderTargetFormat::R16G16_SINT:
143 return PixelFormat::RG16S; 142 return PixelFormat::R16G16_SINT;
144 case Tegra::RenderTargetFormat::RG8_UNORM: 143 case Tegra::RenderTargetFormat::R16G16_UINT:
145 return PixelFormat::RG8U; 144 return PixelFormat::R16G16_UINT;
146 case Tegra::RenderTargetFormat::RG8_SNORM: 145 case Tegra::RenderTargetFormat::R16G16_FLOAT:
147 return PixelFormat::RG8S; 146 return PixelFormat::R16G16_FLOAT;
148 case Tegra::RenderTargetFormat::RG8_UINT: 147 case Tegra::RenderTargetFormat::B10G11R11_FLOAT:
149 return PixelFormat::RG8UI; 148 return PixelFormat::B10G11R11_FLOAT;
150 case Tegra::RenderTargetFormat::R16_FLOAT: 149 case Tegra::RenderTargetFormat::R32_SINT:
151 return PixelFormat::R16F; 150 return PixelFormat::R32_SINT;
151 case Tegra::RenderTargetFormat::R32_UINT:
152 return PixelFormat::R32_UINT;
153 case Tegra::RenderTargetFormat::R32_FLOAT:
154 return PixelFormat::R32_FLOAT;
155 case Tegra::RenderTargetFormat::R5G6B5_UNORM:
156 return PixelFormat::R5G6B5_UNORM;
157 case Tegra::RenderTargetFormat::A1R5G5B5_UNORM:
158 return PixelFormat::A1R5G5B5_UNORM;
159 case Tegra::RenderTargetFormat::R8G8_UNORM:
160 return PixelFormat::R8G8_UNORM;
161 case Tegra::RenderTargetFormat::R8G8_SNORM:
162 return PixelFormat::R8G8_SNORM;
163 case Tegra::RenderTargetFormat::R8G8_SINT:
164 return PixelFormat::R8G8_SINT;
165 case Tegra::RenderTargetFormat::R8G8_UINT:
166 return PixelFormat::R8G8_UINT;
152 case Tegra::RenderTargetFormat::R16_UNORM: 167 case Tegra::RenderTargetFormat::R16_UNORM:
153 return PixelFormat::R16U; 168 return PixelFormat::R16_UNORM;
154 case Tegra::RenderTargetFormat::R16_SNORM: 169 case Tegra::RenderTargetFormat::R16_SNORM:
155 return PixelFormat::R16S; 170 return PixelFormat::R16_SNORM;
156 case Tegra::RenderTargetFormat::R16_UINT:
157 return PixelFormat::R16UI;
158 case Tegra::RenderTargetFormat::R16_SINT: 171 case Tegra::RenderTargetFormat::R16_SINT:
159 return PixelFormat::R16I; 172 return PixelFormat::R16_SINT;
160 case Tegra::RenderTargetFormat::R32_FLOAT: 173 case Tegra::RenderTargetFormat::R16_UINT:
161 return PixelFormat::R32F; 174 return PixelFormat::R16_UINT;
162 case Tegra::RenderTargetFormat::R32_SINT: 175 case Tegra::RenderTargetFormat::R16_FLOAT:
163 return PixelFormat::R32I; 176 return PixelFormat::R16_FLOAT;
164 case Tegra::RenderTargetFormat::R32_UINT: 177 case Tegra::RenderTargetFormat::R8_UNORM:
165 return PixelFormat::R32UI; 178 return PixelFormat::R8_UNORM;
166 case Tegra::RenderTargetFormat::RG32_UINT: 179 case Tegra::RenderTargetFormat::R8_SNORM:
167 return PixelFormat::RG32UI; 180 return PixelFormat::R8_SNORM;
168 case Tegra::RenderTargetFormat::RGBX16_FLOAT: 181 case Tegra::RenderTargetFormat::R8_SINT:
169 return PixelFormat::RGBX16F; 182 return PixelFormat::R8_SINT;
183 case Tegra::RenderTargetFormat::R8_UINT:
184 return PixelFormat::R8_UINT;
170 default: 185 default:
171 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 186 UNIMPLEMENTED_MSG("Unimplemented format={}", static_cast<int>(format));
172 UNREACHABLE(); 187 return PixelFormat::A8B8G8R8_UNORM;
173 return PixelFormat::RGBA8_SRGB;
174 } 188 }
175} 189}
176 190
177PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { 191PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) {
178 switch (format) { 192 switch (format) {
179 case Tegra::FramebufferConfig::PixelFormat::ABGR8: 193 case Tegra::FramebufferConfig::PixelFormat::A8B8G8R8_UNORM:
180 return PixelFormat::ABGR8U; 194 return PixelFormat::A8B8G8R8_UNORM;
181 case Tegra::FramebufferConfig::PixelFormat::RGB565: 195 case Tegra::FramebufferConfig::PixelFormat::RGB565_UNORM:
182 return PixelFormat::B5G6R5U; 196 return PixelFormat::R5G6B5_UNORM;
183 case Tegra::FramebufferConfig::PixelFormat::BGRA8: 197 case Tegra::FramebufferConfig::PixelFormat::B8G8R8A8_UNORM:
184 return PixelFormat::BGRA8; 198 return PixelFormat::B8G8R8A8_UNORM;
185 default: 199 default:
186 UNIMPLEMENTED_MSG("Unimplemented format={}", static_cast<u32>(format)); 200 UNIMPLEMENTED_MSG("Unimplemented format={}", static_cast<u32>(format));
187 return PixelFormat::ABGR8U; 201 return PixelFormat::A8B8G8R8_UNORM;
188 } 202 }
189} 203}
190 204
@@ -212,27 +226,27 @@ SurfaceType GetFormatType(PixelFormat pixel_format) {
212 226
213bool IsPixelFormatASTC(PixelFormat format) { 227bool IsPixelFormatASTC(PixelFormat format) {
214 switch (format) { 228 switch (format) {
215 case PixelFormat::ASTC_2D_4X4: 229 case PixelFormat::ASTC_2D_4X4_UNORM:
216 case PixelFormat::ASTC_2D_5X4: 230 case PixelFormat::ASTC_2D_5X4_UNORM:
217 case PixelFormat::ASTC_2D_5X5: 231 case PixelFormat::ASTC_2D_5X5_UNORM:
218 case PixelFormat::ASTC_2D_8X8: 232 case PixelFormat::ASTC_2D_8X8_UNORM:
219 case PixelFormat::ASTC_2D_8X5: 233 case PixelFormat::ASTC_2D_8X5_UNORM:
220 case PixelFormat::ASTC_2D_4X4_SRGB: 234 case PixelFormat::ASTC_2D_4X4_SRGB:
221 case PixelFormat::ASTC_2D_5X4_SRGB: 235 case PixelFormat::ASTC_2D_5X4_SRGB:
222 case PixelFormat::ASTC_2D_5X5_SRGB: 236 case PixelFormat::ASTC_2D_5X5_SRGB:
223 case PixelFormat::ASTC_2D_8X8_SRGB: 237 case PixelFormat::ASTC_2D_8X8_SRGB:
224 case PixelFormat::ASTC_2D_8X5_SRGB: 238 case PixelFormat::ASTC_2D_8X5_SRGB:
225 case PixelFormat::ASTC_2D_10X8: 239 case PixelFormat::ASTC_2D_10X8_UNORM:
226 case PixelFormat::ASTC_2D_10X8_SRGB: 240 case PixelFormat::ASTC_2D_10X8_SRGB:
227 case PixelFormat::ASTC_2D_6X6: 241 case PixelFormat::ASTC_2D_6X6_UNORM:
228 case PixelFormat::ASTC_2D_6X6_SRGB: 242 case PixelFormat::ASTC_2D_6X6_SRGB:
229 case PixelFormat::ASTC_2D_10X10: 243 case PixelFormat::ASTC_2D_10X10_UNORM:
230 case PixelFormat::ASTC_2D_10X10_SRGB: 244 case PixelFormat::ASTC_2D_10X10_SRGB:
231 case PixelFormat::ASTC_2D_12X12: 245 case PixelFormat::ASTC_2D_12X12_UNORM:
232 case PixelFormat::ASTC_2D_12X12_SRGB: 246 case PixelFormat::ASTC_2D_12X12_SRGB:
233 case PixelFormat::ASTC_2D_8X6: 247 case PixelFormat::ASTC_2D_8X6_UNORM:
234 case PixelFormat::ASTC_2D_8X6_SRGB: 248 case PixelFormat::ASTC_2D_8X6_SRGB:
235 case PixelFormat::ASTC_2D_6X5: 249 case PixelFormat::ASTC_2D_6X5_UNORM:
236 case PixelFormat::ASTC_2D_6X5_SRGB: 250 case PixelFormat::ASTC_2D_6X5_SRGB:
237 return true; 251 return true;
238 default: 252 default:
@@ -242,12 +256,12 @@ bool IsPixelFormatASTC(PixelFormat format) {
242 256
243bool IsPixelFormatSRGB(PixelFormat format) { 257bool IsPixelFormatSRGB(PixelFormat format) {
244 switch (format) { 258 switch (format) {
245 case PixelFormat::RGBA8_SRGB: 259 case PixelFormat::A8B8G8R8_SRGB:
246 case PixelFormat::BGRA8_SRGB: 260 case PixelFormat::B8G8R8A8_SRGB:
247 case PixelFormat::DXT1_SRGB: 261 case PixelFormat::BC1_RGBA_SRGB:
248 case PixelFormat::DXT23_SRGB: 262 case PixelFormat::BC2_SRGB:
249 case PixelFormat::DXT45_SRGB: 263 case PixelFormat::BC3_SRGB:
250 case PixelFormat::BC7U_SRGB: 264 case PixelFormat::BC7_SRGB:
251 case PixelFormat::ASTC_2D_4X4_SRGB: 265 case PixelFormat::ASTC_2D_4X4_SRGB:
252 case PixelFormat::ASTC_2D_8X8_SRGB: 266 case PixelFormat::ASTC_2D_8X8_SRGB:
253 case PixelFormat::ASTC_2D_8X5_SRGB: 267 case PixelFormat::ASTC_2D_8X5_SRGB:
@@ -269,25 +283,4 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
269 return {GetDefaultBlockWidth(format), GetDefaultBlockHeight(format)}; 283 return {GetDefaultBlockWidth(format), GetDefaultBlockHeight(format)};
270} 284}
271 285
272bool IsFormatBCn(PixelFormat format) {
273 switch (format) {
274 case PixelFormat::DXT1:
275 case PixelFormat::DXT23:
276 case PixelFormat::DXT45:
277 case PixelFormat::DXN1:
278 case PixelFormat::DXN2SNORM:
279 case PixelFormat::DXN2UNORM:
280 case PixelFormat::BC7U:
281 case PixelFormat::BC6H_UF16:
282 case PixelFormat::BC6H_SF16:
283 case PixelFormat::DXT1_SRGB:
284 case PixelFormat::DXT23_SRGB:
285 case PixelFormat::DXT45_SRGB:
286 case PixelFormat::BC7U_SRGB:
287 return true;
288 default:
289 return false;
290 }
291}
292
293} // namespace VideoCore::Surface 286} // namespace VideoCore::Surface