summaryrefslogtreecommitdiff
path: root/src/video_core/surface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/surface.cpp')
-rw-r--r--src/video_core/surface.cpp86
1 files changed, 51 insertions, 35 deletions
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index 3b022a456..6384fa8d2 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -178,39 +178,44 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
178 return PixelFormat::ABGR8S; 178 return PixelFormat::ABGR8S;
179 case Tegra::Texture::ComponentType::UINT: 179 case Tegra::Texture::ComponentType::UINT:
180 return PixelFormat::ABGR8UI; 180 return PixelFormat::ABGR8UI;
181 default:
182 break;
181 } 183 }
182 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 184 break;
183 UNREACHABLE();
184 case Tegra::Texture::TextureFormat::B5G6R5: 185 case Tegra::Texture::TextureFormat::B5G6R5:
185 switch (component_type) { 186 switch (component_type) {
186 case Tegra::Texture::ComponentType::UNORM: 187 case Tegra::Texture::ComponentType::UNORM:
187 return PixelFormat::B5G6R5U; 188 return PixelFormat::B5G6R5U;
189 default:
190 break;
188 } 191 }
189 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 192 break;
190 UNREACHABLE();
191 case Tegra::Texture::TextureFormat::A2B10G10R10: 193 case Tegra::Texture::TextureFormat::A2B10G10R10:
192 switch (component_type) { 194 switch (component_type) {
193 case Tegra::Texture::ComponentType::UNORM: 195 case Tegra::Texture::ComponentType::UNORM:
194 return PixelFormat::A2B10G10R10U; 196 return PixelFormat::A2B10G10R10U;
197 default:
198 break;
195 } 199 }
196 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 200 break;
197 UNREACHABLE();
198 case Tegra::Texture::TextureFormat::A1B5G5R5: 201 case Tegra::Texture::TextureFormat::A1B5G5R5:
199 switch (component_type) { 202 switch (component_type) {
200 case Tegra::Texture::ComponentType::UNORM: 203 case Tegra::Texture::ComponentType::UNORM:
201 return PixelFormat::A1B5G5R5U; 204 return PixelFormat::A1B5G5R5U;
205 default:
206 break;
202 } 207 }
203 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 208 break;
204 UNREACHABLE();
205 case Tegra::Texture::TextureFormat::R8: 209 case Tegra::Texture::TextureFormat::R8:
206 switch (component_type) { 210 switch (component_type) {
207 case Tegra::Texture::ComponentType::UNORM: 211 case Tegra::Texture::ComponentType::UNORM:
208 return PixelFormat::R8U; 212 return PixelFormat::R8U;
209 case Tegra::Texture::ComponentType::UINT: 213 case Tegra::Texture::ComponentType::UINT:
210 return PixelFormat::R8UI; 214 return PixelFormat::R8UI;
215 default:
216 break;
211 } 217 }
212 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 218 break;
213 UNREACHABLE();
214 case Tegra::Texture::TextureFormat::G8R8: 219 case Tegra::Texture::TextureFormat::G8R8:
215 // TextureFormat::G8R8 is actually ordered red then green, as such we can use 220 // TextureFormat::G8R8 is actually ordered red then green, as such we can use
216 // PixelFormat::RG8U and PixelFormat::RG8S. This was tested with The Legend of Zelda: Breath 221 // PixelFormat::RG8U and PixelFormat::RG8S. This was tested with The Legend of Zelda: Breath
@@ -220,50 +225,55 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
220 return PixelFormat::RG8U; 225 return PixelFormat::RG8U;
221 case Tegra::Texture::ComponentType::SNORM: 226 case Tegra::Texture::ComponentType::SNORM:
222 return PixelFormat::RG8S; 227 return PixelFormat::RG8S;
228 default:
229 break;
223 } 230 }
224 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 231 break;
225 UNREACHABLE();
226 case Tegra::Texture::TextureFormat::R16_G16_B16_A16: 232 case Tegra::Texture::TextureFormat::R16_G16_B16_A16:
227 switch (component_type) { 233 switch (component_type) {
228 case Tegra::Texture::ComponentType::UNORM: 234 case Tegra::Texture::ComponentType::UNORM:
229 return PixelFormat::RGBA16U; 235 return PixelFormat::RGBA16U;
230 case Tegra::Texture::ComponentType::FLOAT: 236 case Tegra::Texture::ComponentType::FLOAT:
231 return PixelFormat::RGBA16F; 237 return PixelFormat::RGBA16F;
238 default:
239 break;
232 } 240 }
233 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 241 break;
234 UNREACHABLE();
235 case Tegra::Texture::TextureFormat::BF10GF11RF11: 242 case Tegra::Texture::TextureFormat::BF10GF11RF11:
236 switch (component_type) { 243 switch (component_type) {
237 case Tegra::Texture::ComponentType::FLOAT: 244 case Tegra::Texture::ComponentType::FLOAT:
238 return PixelFormat::R11FG11FB10F; 245 return PixelFormat::R11FG11FB10F;
246 default:
247 break;
239 } 248 }
240 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));
241 UNREACHABLE();
242 case Tegra::Texture::TextureFormat::R32_G32_B32_A32: 249 case Tegra::Texture::TextureFormat::R32_G32_B32_A32:
243 switch (component_type) { 250 switch (component_type) {
244 case Tegra::Texture::ComponentType::FLOAT: 251 case Tegra::Texture::ComponentType::FLOAT:
245 return PixelFormat::RGBA32F; 252 return PixelFormat::RGBA32F;
246 case Tegra::Texture::ComponentType::UINT: 253 case Tegra::Texture::ComponentType::UINT:
247 return PixelFormat::RGBA32UI; 254 return PixelFormat::RGBA32UI;
255 default:
256 break;
248 } 257 }
249 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 258 break;
250 UNREACHABLE();
251 case Tegra::Texture::TextureFormat::R32_G32: 259 case Tegra::Texture::TextureFormat::R32_G32:
252 switch (component_type) { 260 switch (component_type) {
253 case Tegra::Texture::ComponentType::FLOAT: 261 case Tegra::Texture::ComponentType::FLOAT:
254 return PixelFormat::RG32F; 262 return PixelFormat::RG32F;
255 case Tegra::Texture::ComponentType::UINT: 263 case Tegra::Texture::ComponentType::UINT:
256 return PixelFormat::RG32UI; 264 return PixelFormat::RG32UI;
265 default:
266 break;
257 } 267 }
258 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 268 break;
259 UNREACHABLE();
260 case Tegra::Texture::TextureFormat::R32_G32_B32: 269 case Tegra::Texture::TextureFormat::R32_G32_B32:
261 switch (component_type) { 270 switch (component_type) {
262 case Tegra::Texture::ComponentType::FLOAT: 271 case Tegra::Texture::ComponentType::FLOAT:
263 return PixelFormat::RGB32F; 272 return PixelFormat::RGB32F;
273 default:
274 break;
264 } 275 }
265 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 276 break;
266 UNREACHABLE();
267 case Tegra::Texture::TextureFormat::R16: 277 case Tegra::Texture::TextureFormat::R16:
268 switch (component_type) { 278 switch (component_type) {
269 case Tegra::Texture::ComponentType::FLOAT: 279 case Tegra::Texture::ComponentType::FLOAT:
@@ -276,18 +286,20 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
276 return PixelFormat::R16UI; 286 return PixelFormat::R16UI;
277 case Tegra::Texture::ComponentType::SINT: 287 case Tegra::Texture::ComponentType::SINT:
278 return PixelFormat::R16I; 288 return PixelFormat::R16I;
289 default:
290 break;
279 } 291 }
280 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 292 break;
281 UNREACHABLE();
282 case Tegra::Texture::TextureFormat::R32: 293 case Tegra::Texture::TextureFormat::R32:
283 switch (component_type) { 294 switch (component_type) {
284 case Tegra::Texture::ComponentType::FLOAT: 295 case Tegra::Texture::ComponentType::FLOAT:
285 return PixelFormat::R32F; 296 return PixelFormat::R32F;
286 case Tegra::Texture::ComponentType::UINT: 297 case Tegra::Texture::ComponentType::UINT:
287 return PixelFormat::R32UI; 298 return PixelFormat::R32UI;
299 default:
300 break;
288 } 301 }
289 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 302 break;
290 UNREACHABLE();
291 case Tegra::Texture::TextureFormat::ZF32: 303 case Tegra::Texture::TextureFormat::ZF32:
292 return PixelFormat::Z32F; 304 return PixelFormat::Z32F;
293 case Tegra::Texture::TextureFormat::Z16: 305 case Tegra::Texture::TextureFormat::Z16:
@@ -310,9 +322,10 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
310 return PixelFormat::DXN2UNORM; 322 return PixelFormat::DXN2UNORM;
311 case Tegra::Texture::ComponentType::SNORM: 323 case Tegra::Texture::ComponentType::SNORM:
312 return PixelFormat::DXN2SNORM; 324 return PixelFormat::DXN2SNORM;
325 default:
326 break;
313 } 327 }
314 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 328 break;
315 UNREACHABLE();
316 case Tegra::Texture::TextureFormat::BC7U: 329 case Tegra::Texture::TextureFormat::BC7U:
317 return is_srgb ? PixelFormat::BC7U_SRGB : PixelFormat::BC7U; 330 return is_srgb ? PixelFormat::BC7U_SRGB : PixelFormat::BC7U;
318 case Tegra::Texture::TextureFormat::BC6H_UF16: 331 case Tegra::Texture::TextureFormat::BC6H_UF16:
@@ -343,15 +356,17 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
343 return PixelFormat::RG16UI; 356 return PixelFormat::RG16UI;
344 case Tegra::Texture::ComponentType::SINT: 357 case Tegra::Texture::ComponentType::SINT:
345 return PixelFormat::RG16I; 358 return PixelFormat::RG16I;
359 default:
360 break;
346 } 361 }
347 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); 362 break;
348 UNREACHABLE();
349 default: 363 default:
350 LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format), 364 break;
351 static_cast<u32>(component_type));
352 UNREACHABLE();
353 return PixelFormat::ABGR8U;
354 } 365 }
366 LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format),
367 static_cast<u32>(component_type));
368 UNREACHABLE();
369 return PixelFormat::ABGR8U;
355} 370}
356 371
357ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) { 372ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) {
@@ -513,8 +528,9 @@ bool IsFormatBCn(PixelFormat format) {
513 case PixelFormat::DXT45_SRGB: 528 case PixelFormat::DXT45_SRGB:
514 case PixelFormat::BC7U_SRGB: 529 case PixelFormat::BC7U_SRGB:
515 return true; 530 return true;
531 default:
532 return false;
516 } 533 }
517 return false;
518} 534}
519 535
520} // namespace VideoCore::Surface 536} // namespace VideoCore::Surface