diff options
Diffstat (limited to 'src/video_core/surface.cpp')
| -rw-r--r-- | src/video_core/surface.cpp | 321 |
1 files changed, 0 insertions, 321 deletions
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 4b6846113..1655ccf16 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -168,311 +168,6 @@ PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) | |||
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format, | ||
| 172 | Tegra::Texture::ComponentType component_type, | ||
| 173 | bool is_srgb) { | ||
| 174 | // TODO(Subv): Properly implement this | ||
| 175 | switch (format) { | ||
| 176 | case Tegra::Texture::TextureFormat::A8R8G8B8: | ||
| 177 | if (is_srgb) { | ||
| 178 | return PixelFormat::RGBA8_SRGB; | ||
| 179 | } | ||
| 180 | switch (component_type) { | ||
| 181 | case Tegra::Texture::ComponentType::UNORM: | ||
| 182 | return PixelFormat::ABGR8U; | ||
| 183 | case Tegra::Texture::ComponentType::SNORM: | ||
| 184 | return PixelFormat::ABGR8S; | ||
| 185 | case Tegra::Texture::ComponentType::UINT: | ||
| 186 | return PixelFormat::ABGR8UI; | ||
| 187 | default: | ||
| 188 | break; | ||
| 189 | } | ||
| 190 | break; | ||
| 191 | case Tegra::Texture::TextureFormat::B5G6R5: | ||
| 192 | switch (component_type) { | ||
| 193 | case Tegra::Texture::ComponentType::UNORM: | ||
| 194 | return PixelFormat::B5G6R5U; | ||
| 195 | default: | ||
| 196 | break; | ||
| 197 | } | ||
| 198 | break; | ||
| 199 | case Tegra::Texture::TextureFormat::A2B10G10R10: | ||
| 200 | switch (component_type) { | ||
| 201 | case Tegra::Texture::ComponentType::UNORM: | ||
| 202 | return PixelFormat::A2B10G10R10U; | ||
| 203 | default: | ||
| 204 | break; | ||
| 205 | } | ||
| 206 | break; | ||
| 207 | case Tegra::Texture::TextureFormat::A1B5G5R5: | ||
| 208 | switch (component_type) { | ||
| 209 | case Tegra::Texture::ComponentType::UNORM: | ||
| 210 | return PixelFormat::A1B5G5R5U; | ||
| 211 | default: | ||
| 212 | break; | ||
| 213 | } | ||
| 214 | break; | ||
| 215 | case Tegra::Texture::TextureFormat::A4B4G4R4: | ||
| 216 | switch (component_type) { | ||
| 217 | case Tegra::Texture::ComponentType::UNORM: | ||
| 218 | return PixelFormat::R4G4B4A4U; | ||
| 219 | default: | ||
| 220 | break; | ||
| 221 | } | ||
| 222 | break; | ||
| 223 | case Tegra::Texture::TextureFormat::R8: | ||
| 224 | switch (component_type) { | ||
| 225 | case Tegra::Texture::ComponentType::UNORM: | ||
| 226 | return PixelFormat::R8U; | ||
| 227 | case Tegra::Texture::ComponentType::UINT: | ||
| 228 | return PixelFormat::R8UI; | ||
| 229 | default: | ||
| 230 | break; | ||
| 231 | } | ||
| 232 | break; | ||
| 233 | case Tegra::Texture::TextureFormat::G8R8: | ||
| 234 | // TextureFormat::G8R8 is actually ordered red then green, as such we can use | ||
| 235 | // PixelFormat::RG8U and PixelFormat::RG8S. This was tested with The Legend of Zelda: Breath | ||
| 236 | // of the Wild, which uses this format to render the hearts on the UI. | ||
| 237 | switch (component_type) { | ||
| 238 | case Tegra::Texture::ComponentType::UNORM: | ||
| 239 | return PixelFormat::RG8U; | ||
| 240 | case Tegra::Texture::ComponentType::SNORM: | ||
| 241 | return PixelFormat::RG8S; | ||
| 242 | default: | ||
| 243 | break; | ||
| 244 | } | ||
| 245 | break; | ||
| 246 | case Tegra::Texture::TextureFormat::R16_G16_B16_A16: | ||
| 247 | switch (component_type) { | ||
| 248 | case Tegra::Texture::ComponentType::UNORM: | ||
| 249 | return PixelFormat::RGBA16U; | ||
| 250 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 251 | return PixelFormat::RGBA16F; | ||
| 252 | case Tegra::Texture::ComponentType::UINT: | ||
| 253 | return PixelFormat::RGBA16UI; | ||
| 254 | default: | ||
| 255 | break; | ||
| 256 | } | ||
| 257 | break; | ||
| 258 | case Tegra::Texture::TextureFormat::BF10GF11RF11: | ||
| 259 | switch (component_type) { | ||
| 260 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 261 | return PixelFormat::R11FG11FB10F; | ||
| 262 | default: | ||
| 263 | break; | ||
| 264 | } | ||
| 265 | break; | ||
| 266 | case Tegra::Texture::TextureFormat::R32_G32_B32_A32: | ||
| 267 | switch (component_type) { | ||
| 268 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 269 | return PixelFormat::RGBA32F; | ||
| 270 | case Tegra::Texture::ComponentType::UINT: | ||
| 271 | return PixelFormat::RGBA32UI; | ||
| 272 | default: | ||
| 273 | break; | ||
| 274 | } | ||
| 275 | break; | ||
| 276 | case Tegra::Texture::TextureFormat::R32_G32: | ||
| 277 | switch (component_type) { | ||
| 278 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 279 | return PixelFormat::RG32F; | ||
| 280 | case Tegra::Texture::ComponentType::UINT: | ||
| 281 | return PixelFormat::RG32UI; | ||
| 282 | default: | ||
| 283 | break; | ||
| 284 | } | ||
| 285 | break; | ||
| 286 | case Tegra::Texture::TextureFormat::R32_G32_B32: | ||
| 287 | switch (component_type) { | ||
| 288 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 289 | return PixelFormat::RGB32F; | ||
| 290 | default: | ||
| 291 | break; | ||
| 292 | } | ||
| 293 | break; | ||
| 294 | case Tegra::Texture::TextureFormat::R16: | ||
| 295 | switch (component_type) { | ||
| 296 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 297 | return PixelFormat::R16F; | ||
| 298 | case Tegra::Texture::ComponentType::UNORM: | ||
| 299 | return PixelFormat::R16U; | ||
| 300 | case Tegra::Texture::ComponentType::SNORM: | ||
| 301 | return PixelFormat::R16S; | ||
| 302 | case Tegra::Texture::ComponentType::UINT: | ||
| 303 | return PixelFormat::R16UI; | ||
| 304 | case Tegra::Texture::ComponentType::SINT: | ||
| 305 | return PixelFormat::R16I; | ||
| 306 | default: | ||
| 307 | break; | ||
| 308 | } | ||
| 309 | break; | ||
| 310 | case Tegra::Texture::TextureFormat::R32: | ||
| 311 | switch (component_type) { | ||
| 312 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 313 | return PixelFormat::R32F; | ||
| 314 | case Tegra::Texture::ComponentType::UINT: | ||
| 315 | return PixelFormat::R32UI; | ||
| 316 | default: | ||
| 317 | break; | ||
| 318 | } | ||
| 319 | break; | ||
| 320 | case Tegra::Texture::TextureFormat::E5B9G9R9_SHAREDEXP: | ||
| 321 | switch (component_type) { | ||
| 322 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 323 | return PixelFormat::E5B9G9R9F; | ||
| 324 | default: | ||
| 325 | break; | ||
| 326 | } | ||
| 327 | break; | ||
| 328 | case Tegra::Texture::TextureFormat::ZF32: | ||
| 329 | return PixelFormat::Z32F; | ||
| 330 | case Tegra::Texture::TextureFormat::Z16: | ||
| 331 | return PixelFormat::Z16; | ||
| 332 | case Tegra::Texture::TextureFormat::S8Z24: | ||
| 333 | return PixelFormat::S8Z24; | ||
| 334 | case Tegra::Texture::TextureFormat::ZF32_X24S8: | ||
| 335 | return PixelFormat::Z32FS8; | ||
| 336 | case Tegra::Texture::TextureFormat::DXT1: | ||
| 337 | return is_srgb ? PixelFormat::DXT1_SRGB : PixelFormat::DXT1; | ||
| 338 | case Tegra::Texture::TextureFormat::DXT23: | ||
| 339 | return is_srgb ? PixelFormat::DXT23_SRGB : PixelFormat::DXT23; | ||
| 340 | case Tegra::Texture::TextureFormat::DXT45: | ||
| 341 | return is_srgb ? PixelFormat::DXT45_SRGB : PixelFormat::DXT45; | ||
| 342 | case Tegra::Texture::TextureFormat::DXN1: | ||
| 343 | return PixelFormat::DXN1; | ||
| 344 | case Tegra::Texture::TextureFormat::DXN2: | ||
| 345 | switch (component_type) { | ||
| 346 | case Tegra::Texture::ComponentType::UNORM: | ||
| 347 | return PixelFormat::DXN2UNORM; | ||
| 348 | case Tegra::Texture::ComponentType::SNORM: | ||
| 349 | return PixelFormat::DXN2SNORM; | ||
| 350 | default: | ||
| 351 | break; | ||
| 352 | } | ||
| 353 | break; | ||
| 354 | case Tegra::Texture::TextureFormat::BC7U: | ||
| 355 | return is_srgb ? PixelFormat::BC7U_SRGB : PixelFormat::BC7U; | ||
| 356 | case Tegra::Texture::TextureFormat::BC6H_UF16: | ||
| 357 | return PixelFormat::BC6H_UF16; | ||
| 358 | case Tegra::Texture::TextureFormat::BC6H_SF16: | ||
| 359 | return PixelFormat::BC6H_SF16; | ||
| 360 | case Tegra::Texture::TextureFormat::ASTC_2D_4X4: | ||
| 361 | return is_srgb ? PixelFormat::ASTC_2D_4X4_SRGB : PixelFormat::ASTC_2D_4X4; | ||
| 362 | case Tegra::Texture::TextureFormat::ASTC_2D_5X4: | ||
| 363 | return is_srgb ? PixelFormat::ASTC_2D_5X4_SRGB : PixelFormat::ASTC_2D_5X4; | ||
| 364 | case Tegra::Texture::TextureFormat::ASTC_2D_5X5: | ||
| 365 | return is_srgb ? PixelFormat::ASTC_2D_5X5_SRGB : PixelFormat::ASTC_2D_5X5; | ||
| 366 | case Tegra::Texture::TextureFormat::ASTC_2D_8X8: | ||
| 367 | return is_srgb ? PixelFormat::ASTC_2D_8X8_SRGB : PixelFormat::ASTC_2D_8X8; | ||
| 368 | case Tegra::Texture::TextureFormat::ASTC_2D_8X5: | ||
| 369 | return is_srgb ? PixelFormat::ASTC_2D_8X5_SRGB : PixelFormat::ASTC_2D_8X5; | ||
| 370 | case Tegra::Texture::TextureFormat::ASTC_2D_10X8: | ||
| 371 | return is_srgb ? PixelFormat::ASTC_2D_10X8_SRGB : PixelFormat::ASTC_2D_10X8; | ||
| 372 | case Tegra::Texture::TextureFormat::ASTC_2D_6X6: | ||
| 373 | return is_srgb ? PixelFormat::ASTC_2D_6X6_SRGB : PixelFormat::ASTC_2D_6X6; | ||
| 374 | case Tegra::Texture::TextureFormat::ASTC_2D_10X10: | ||
| 375 | return is_srgb ? PixelFormat::ASTC_2D_10X10_SRGB : PixelFormat::ASTC_2D_10X10; | ||
| 376 | case Tegra::Texture::TextureFormat::ASTC_2D_12X12: | ||
| 377 | return is_srgb ? PixelFormat::ASTC_2D_12X12_SRGB : PixelFormat::ASTC_2D_12X12; | ||
| 378 | case Tegra::Texture::TextureFormat::ASTC_2D_8X6: | ||
| 379 | return is_srgb ? PixelFormat::ASTC_2D_8X6_SRGB : PixelFormat::ASTC_2D_8X6; | ||
| 380 | case Tegra::Texture::TextureFormat::ASTC_2D_6X5: | ||
| 381 | return is_srgb ? PixelFormat::ASTC_2D_6X5_SRGB : PixelFormat::ASTC_2D_6X5; | ||
| 382 | case Tegra::Texture::TextureFormat::R16_G16: | ||
| 383 | switch (component_type) { | ||
| 384 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 385 | return PixelFormat::RG16F; | ||
| 386 | case Tegra::Texture::ComponentType::UNORM: | ||
| 387 | return PixelFormat::RG16; | ||
| 388 | case Tegra::Texture::ComponentType::SNORM: | ||
| 389 | return PixelFormat::RG16S; | ||
| 390 | case Tegra::Texture::ComponentType::UINT: | ||
| 391 | return PixelFormat::RG16UI; | ||
| 392 | case Tegra::Texture::ComponentType::SINT: | ||
| 393 | return PixelFormat::RG16I; | ||
| 394 | default: | ||
| 395 | break; | ||
| 396 | } | ||
| 397 | break; | ||
| 398 | default: | ||
| 399 | break; | ||
| 400 | } | ||
| 401 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format), | ||
| 402 | static_cast<u32>(component_type)); | ||
| 403 | UNREACHABLE(); | ||
| 404 | return PixelFormat::ABGR8U; | ||
| 405 | } | ||
| 406 | |||
| 407 | ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) { | ||
| 408 | // TODO(Subv): Implement more component types | ||
| 409 | switch (type) { | ||
| 410 | case Tegra::Texture::ComponentType::UNORM: | ||
| 411 | return ComponentType::UNorm; | ||
| 412 | case Tegra::Texture::ComponentType::FLOAT: | ||
| 413 | return ComponentType::Float; | ||
| 414 | case Tegra::Texture::ComponentType::SNORM: | ||
| 415 | return ComponentType::SNorm; | ||
| 416 | case Tegra::Texture::ComponentType::UINT: | ||
| 417 | return ComponentType::UInt; | ||
| 418 | case Tegra::Texture::ComponentType::SINT: | ||
| 419 | return ComponentType::SInt; | ||
| 420 | default: | ||
| 421 | LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type)); | ||
| 422 | UNREACHABLE(); | ||
| 423 | return ComponentType::UNorm; | ||
| 424 | } | ||
| 425 | } | ||
| 426 | |||
| 427 | ComponentType ComponentTypeFromRenderTarget(Tegra::RenderTargetFormat format) { | ||
| 428 | // TODO(Subv): Implement more render targets | ||
| 429 | switch (format) { | ||
| 430 | case Tegra::RenderTargetFormat::RGBA8_UNORM: | ||
| 431 | case Tegra::RenderTargetFormat::RGBA8_SRGB: | ||
| 432 | case Tegra::RenderTargetFormat::BGRA8_UNORM: | ||
| 433 | case Tegra::RenderTargetFormat::BGRA8_SRGB: | ||
| 434 | case Tegra::RenderTargetFormat::RGB10_A2_UNORM: | ||
| 435 | case Tegra::RenderTargetFormat::R8_UNORM: | ||
| 436 | case Tegra::RenderTargetFormat::RG16_UNORM: | ||
| 437 | case Tegra::RenderTargetFormat::R16_UNORM: | ||
| 438 | case Tegra::RenderTargetFormat::B5G6R5_UNORM: | ||
| 439 | case Tegra::RenderTargetFormat::BGR5A1_UNORM: | ||
| 440 | case Tegra::RenderTargetFormat::RG8_UNORM: | ||
| 441 | case Tegra::RenderTargetFormat::RGBA16_UNORM: | ||
| 442 | return ComponentType::UNorm; | ||
| 443 | case Tegra::RenderTargetFormat::RGBA8_SNORM: | ||
| 444 | case Tegra::RenderTargetFormat::RG16_SNORM: | ||
| 445 | case Tegra::RenderTargetFormat::R16_SNORM: | ||
| 446 | case Tegra::RenderTargetFormat::RG8_SNORM: | ||
| 447 | return ComponentType::SNorm; | ||
| 448 | case Tegra::RenderTargetFormat::RGBA16_FLOAT: | ||
| 449 | case Tegra::RenderTargetFormat::RGBX16_FLOAT: | ||
| 450 | case Tegra::RenderTargetFormat::R11G11B10_FLOAT: | ||
| 451 | case Tegra::RenderTargetFormat::RGBA32_FLOAT: | ||
| 452 | case Tegra::RenderTargetFormat::RG32_FLOAT: | ||
| 453 | case Tegra::RenderTargetFormat::RG16_FLOAT: | ||
| 454 | case Tegra::RenderTargetFormat::R16_FLOAT: | ||
| 455 | case Tegra::RenderTargetFormat::R32_FLOAT: | ||
| 456 | return ComponentType::Float; | ||
| 457 | case Tegra::RenderTargetFormat::RGBA32_UINT: | ||
| 458 | case Tegra::RenderTargetFormat::RGBA16_UINT: | ||
| 459 | case Tegra::RenderTargetFormat::RG16_UINT: | ||
| 460 | case Tegra::RenderTargetFormat::R8_UINT: | ||
| 461 | case Tegra::RenderTargetFormat::R16_UINT: | ||
| 462 | case Tegra::RenderTargetFormat::RG32_UINT: | ||
| 463 | case Tegra::RenderTargetFormat::R32_UINT: | ||
| 464 | case Tegra::RenderTargetFormat::RGBA8_UINT: | ||
| 465 | return ComponentType::UInt; | ||
| 466 | case Tegra::RenderTargetFormat::RG16_SINT: | ||
| 467 | case Tegra::RenderTargetFormat::R16_SINT: | ||
| 468 | return ComponentType::SInt; | ||
| 469 | default: | ||
| 470 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | ||
| 471 | UNREACHABLE(); | ||
| 472 | return ComponentType::UNorm; | ||
| 473 | } | ||
| 474 | } | ||
| 475 | |||
| 476 | PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { | 171 | PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { |
| 477 | switch (format) { | 172 | switch (format) { |
| 478 | case Tegra::FramebufferConfig::PixelFormat::ABGR8: | 173 | case Tegra::FramebufferConfig::PixelFormat::ABGR8: |
| @@ -487,22 +182,6 @@ PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat | |||
| 487 | } | 182 | } |
| 488 | } | 183 | } |
| 489 | 184 | ||
| 490 | ComponentType ComponentTypeFromDepthFormat(Tegra::DepthFormat format) { | ||
| 491 | switch (format) { | ||
| 492 | case Tegra::DepthFormat::Z16_UNORM: | ||
| 493 | case Tegra::DepthFormat::S8_Z24_UNORM: | ||
| 494 | case Tegra::DepthFormat::Z24_S8_UNORM: | ||
| 495 | return ComponentType::UNorm; | ||
| 496 | case Tegra::DepthFormat::Z32_FLOAT: | ||
| 497 | case Tegra::DepthFormat::Z32_S8_X24_FLOAT: | ||
| 498 | return ComponentType::Float; | ||
| 499 | default: | ||
| 500 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | ||
| 501 | UNREACHABLE(); | ||
| 502 | return ComponentType::UNorm; | ||
| 503 | } | ||
| 504 | } | ||
| 505 | |||
| 506 | SurfaceType GetFormatType(PixelFormat pixel_format) { | 185 | SurfaceType GetFormatType(PixelFormat pixel_format) { |
| 507 | if (static_cast<std::size_t>(pixel_format) < | 186 | if (static_cast<std::size_t>(pixel_format) < |
| 508 | static_cast<std::size_t>(PixelFormat::MaxColorFormat)) { | 187 | static_cast<std::size_t>(PixelFormat::MaxColorFormat)) { |