diff options
| author | 2018-08-10 11:44:43 -0400 | |
|---|---|---|
| committer | 2018-08-11 18:59:14 -0400 | |
| commit | 0471976b48d14327455bfaede7bab3a3c667f866 (patch) | |
| tree | 3b79dc6e1ef09b0474e26606581a35eae1a0640f /src | |
| parent | Merge pull request #1016 from lioncash/video (diff) | |
| download | yuzu-0471976b48d14327455bfaede7bab3a3c667f866.tar.gz yuzu-0471976b48d14327455bfaede7bab3a3c667f866.tar.xz yuzu-0471976b48d14327455bfaede7bab3a3c667f866.zip | |
gl_rasterizer: Implement render target format RGBA8_SNORM.
- Used by Super Mario Odyssey.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/gpu.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 45 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 100 |
4 files changed, 83 insertions, 64 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index ceaf86654..e0fc10a51 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -50,6 +50,7 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { | |||
| 50 | case RenderTargetFormat::RG32_FLOAT: | 50 | case RenderTargetFormat::RG32_FLOAT: |
| 51 | return 8; | 51 | return 8; |
| 52 | case RenderTargetFormat::RGBA8_UNORM: | 52 | case RenderTargetFormat::RGBA8_UNORM: |
| 53 | case RenderTargetFormat::RGBA8_SNORM: | ||
| 53 | case RenderTargetFormat::RGBA8_SRGB: | 54 | case RenderTargetFormat::RGBA8_SRGB: |
| 54 | case RenderTargetFormat::RGB10_A2_UNORM: | 55 | case RenderTargetFormat::RGB10_A2_UNORM: |
| 55 | case RenderTargetFormat::BGRA8_UNORM: | 56 | case RenderTargetFormat::BGRA8_UNORM: |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index b57312b3b..36918ca16 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -26,6 +26,7 @@ enum class RenderTargetFormat : u32 { | |||
| 26 | RGB10_A2_UNORM = 0xD1, | 26 | RGB10_A2_UNORM = 0xD1, |
| 27 | RGBA8_UNORM = 0xD5, | 27 | RGBA8_UNORM = 0xD5, |
| 28 | RGBA8_SRGB = 0xD6, | 28 | RGBA8_SRGB = 0xD6, |
| 29 | RGBA8_SNORM = 0xD7, | ||
| 29 | RG16_UNORM = 0xDA, | 30 | RG16_UNORM = 0xDA, |
| 30 | RG16_SNORM = 0xDB, | 31 | RG16_SNORM = 0xDB, |
| 31 | RG16_SINT = 0xDC, | 32 | RG16_SINT = 0xDC, |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 15a33ed9b..5b09236ca 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -92,7 +92,8 @@ struct FormatTuple { | |||
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ | 94 | static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ |
| 95 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // ABGR8 | 95 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // ABGR8U |
| 96 | {GL_RGBA8, GL_RGBA, GL_BYTE, ComponentType::SNorm, false}, // ABGR8S | ||
| 96 | {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, ComponentType::UNorm, false}, // B5G6R5 | 97 | {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, ComponentType::UNorm, false}, // B5G6R5 |
| 97 | {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, ComponentType::UNorm, | 98 | {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, ComponentType::UNorm, |
| 98 | false}, // A2B10G10R10 | 99 | false}, // A2B10G10R10 |
| @@ -231,31 +232,33 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, std::vector<u8>& gl_bu | |||
| 231 | static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPUVAddr), | 232 | static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPUVAddr), |
| 232 | SurfaceParams::MaxPixelFormat> | 233 | SurfaceParams::MaxPixelFormat> |
| 233 | morton_to_gl_fns = { | 234 | morton_to_gl_fns = { |
| 234 | MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>, | 235 | MortonCopy<true, PixelFormat::ABGR8U>, MortonCopy<true, PixelFormat::ABGR8S>, |
| 235 | MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>, | 236 | MortonCopy<true, PixelFormat::B5G6R5>, MortonCopy<true, PixelFormat::A2B10G10R10>, |
| 236 | MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>, | 237 | MortonCopy<true, PixelFormat::A1B5G5R5>, MortonCopy<true, PixelFormat::R8>, |
| 237 | MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>, | 238 | MortonCopy<true, PixelFormat::RGBA16F>, MortonCopy<true, PixelFormat::R11FG11FB10F>, |
| 238 | MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, | 239 | MortonCopy<true, PixelFormat::RGBA32UI>, MortonCopy<true, PixelFormat::DXT1>, |
| 239 | MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, | 240 | MortonCopy<true, PixelFormat::DXT23>, MortonCopy<true, PixelFormat::DXT45>, |
| 240 | MortonCopy<true, PixelFormat::DXN2UNORM>, MortonCopy<true, PixelFormat::DXN2SNORM>, | 241 | MortonCopy<true, PixelFormat::DXN1>, MortonCopy<true, PixelFormat::DXN2UNORM>, |
| 241 | MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, | 242 | MortonCopy<true, PixelFormat::DXN2SNORM>, MortonCopy<true, PixelFormat::BC7U>, |
| 242 | MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, | 243 | MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::G8R8>, |
| 243 | MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, | 244 | MortonCopy<true, PixelFormat::BGRA8>, MortonCopy<true, PixelFormat::RGBA32F>, |
| 244 | MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>, | 245 | MortonCopy<true, PixelFormat::RG32F>, MortonCopy<true, PixelFormat::R32F>, |
| 245 | MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::R16S>, | 246 | MortonCopy<true, PixelFormat::R16F>, MortonCopy<true, PixelFormat::R16UNORM>, |
| 246 | MortonCopy<true, PixelFormat::R16UI>, MortonCopy<true, PixelFormat::R16I>, | 247 | MortonCopy<true, PixelFormat::R16S>, MortonCopy<true, PixelFormat::R16UI>, |
| 247 | MortonCopy<true, PixelFormat::RG16>, MortonCopy<true, PixelFormat::RG16F>, | 248 | MortonCopy<true, PixelFormat::R16I>, MortonCopy<true, PixelFormat::RG16>, |
| 248 | MortonCopy<true, PixelFormat::RG16UI>, MortonCopy<true, PixelFormat::RG16I>, | 249 | MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>, |
| 249 | MortonCopy<true, PixelFormat::RG16S>, MortonCopy<true, PixelFormat::RGB32F>, | 250 | MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>, |
| 250 | MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::Z24S8>, | 251 | MortonCopy<true, PixelFormat::RGB32F>, MortonCopy<true, PixelFormat::SRGBA8>, |
| 251 | MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, | 252 | MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, |
| 252 | MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32FS8>, | 253 | MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, |
| 254 | MortonCopy<true, PixelFormat::Z32FS8>, | ||
| 253 | }; | 255 | }; |
| 254 | 256 | ||
| 255 | static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPUVAddr), | 257 | static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPUVAddr), |
| 256 | SurfaceParams::MaxPixelFormat> | 258 | SurfaceParams::MaxPixelFormat> |
| 257 | gl_to_morton_fns = { | 259 | gl_to_morton_fns = { |
| 258 | MortonCopy<false, PixelFormat::ABGR8>, | 260 | MortonCopy<false, PixelFormat::ABGR8U>, |
| 261 | MortonCopy<false, PixelFormat::ABGR8S>, | ||
| 259 | MortonCopy<false, PixelFormat::B5G6R5>, | 262 | MortonCopy<false, PixelFormat::B5G6R5>, |
| 260 | MortonCopy<false, PixelFormat::A2B10G10R10>, | 263 | MortonCopy<false, PixelFormat::A2B10G10R10>, |
| 261 | MortonCopy<false, PixelFormat::A1B5G5R5>, | 264 | MortonCopy<false, PixelFormat::A1B5G5R5>, |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index e24ba8cfe..826ad2930 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -23,48 +23,49 @@ using PageMap = boost::icl::interval_map<u64, int>; | |||
| 23 | 23 | ||
| 24 | struct SurfaceParams { | 24 | struct SurfaceParams { |
| 25 | enum class PixelFormat { | 25 | enum class PixelFormat { |
| 26 | ABGR8 = 0, | 26 | ABGR8U = 0, |
| 27 | B5G6R5 = 1, | 27 | ABGR8S = 1, |
| 28 | A2B10G10R10 = 2, | 28 | B5G6R5 = 2, |
| 29 | A1B5G5R5 = 3, | 29 | A2B10G10R10 = 3, |
| 30 | R8 = 4, | 30 | A1B5G5R5 = 4, |
| 31 | RGBA16F = 5, | 31 | R8 = 5, |
| 32 | R11FG11FB10F = 6, | 32 | RGBA16F = 6, |
| 33 | RGBA32UI = 7, | 33 | R11FG11FB10F = 7, |
| 34 | DXT1 = 8, | 34 | RGBA32UI = 8, |
| 35 | DXT23 = 9, | 35 | DXT1 = 9, |
| 36 | DXT45 = 10, | 36 | DXT23 = 10, |
| 37 | DXN1 = 11, // This is also known as BC4 | 37 | DXT45 = 11, |
| 38 | DXN2UNORM = 12, | 38 | DXN1 = 12, // This is also known as BC4 |
| 39 | DXN2SNORM = 13, | 39 | DXN2UNORM = 13, |
| 40 | BC7U = 14, | 40 | DXN2SNORM = 14, |
| 41 | ASTC_2D_4X4 = 15, | 41 | BC7U = 15, |
| 42 | G8R8 = 16, | 42 | ASTC_2D_4X4 = 16, |
| 43 | BGRA8 = 17, | 43 | G8R8 = 17, |
| 44 | RGBA32F = 18, | 44 | BGRA8 = 18, |
| 45 | RG32F = 19, | 45 | RGBA32F = 19, |
| 46 | R32F = 20, | 46 | RG32F = 20, |
| 47 | R16F = 21, | 47 | R32F = 21, |
| 48 | R16UNORM = 22, | 48 | R16F = 22, |
| 49 | R16S = 23, | 49 | R16UNORM = 23, |
| 50 | R16UI = 24, | 50 | R16S = 24, |
| 51 | R16I = 25, | 51 | R16UI = 25, |
| 52 | RG16 = 26, | 52 | R16I = 26, |
| 53 | RG16F = 27, | 53 | RG16 = 27, |
| 54 | RG16UI = 28, | 54 | RG16F = 28, |
| 55 | RG16I = 29, | 55 | RG16UI = 29, |
| 56 | RG16S = 30, | 56 | RG16I = 30, |
| 57 | RGB32F = 31, | 57 | RG16S = 31, |
| 58 | SRGBA8 = 32, | 58 | RGB32F = 32, |
| 59 | SRGBA8 = 33, | ||
| 59 | 60 | ||
| 60 | MaxColorFormat, | 61 | MaxColorFormat, |
| 61 | 62 | ||
| 62 | // DepthStencil formats | 63 | // DepthStencil formats |
| 63 | Z24S8 = 33, | 64 | Z24S8 = 34, |
| 64 | S8Z24 = 34, | 65 | S8Z24 = 35, |
| 65 | Z32F = 35, | 66 | Z32F = 36, |
| 66 | Z16 = 36, | 67 | Z16 = 37, |
| 67 | Z32FS8 = 37, | 68 | Z32FS8 = 38, |
| 68 | 69 | ||
| 69 | MaxDepthStencilFormat, | 70 | MaxDepthStencilFormat, |
| 70 | 71 | ||
| @@ -102,7 +103,8 @@ struct SurfaceParams { | |||
| 102 | return 0; | 103 | return 0; |
| 103 | 104 | ||
| 104 | constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{ | 105 | constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{ |
| 105 | 1, // ABGR8 | 106 | 1, // ABGR8U |
| 107 | 1, // ABGR8S | ||
| 106 | 1, // B5G6R5 | 108 | 1, // B5G6R5 |
| 107 | 1, // A2B10G10R10 | 109 | 1, // A2B10G10R10 |
| 108 | 1, // A1B5G5R5 | 110 | 1, // A1B5G5R5 |
| @@ -151,7 +153,8 @@ struct SurfaceParams { | |||
| 151 | return 0; | 153 | return 0; |
| 152 | 154 | ||
| 153 | constexpr std::array<u32, MaxPixelFormat> bpp_table = {{ | 155 | constexpr std::array<u32, MaxPixelFormat> bpp_table = {{ |
| 154 | 32, // ABGR8 | 156 | 32, // ABGR8U |
| 157 | 32, // ABGR8S | ||
| 155 | 16, // B5G6R5 | 158 | 16, // B5G6R5 |
| 156 | 32, // A2B10G10R10 | 159 | 32, // A2B10G10R10 |
| 157 | 16, // A1B5G5R5 | 160 | 16, // A1B5G5R5 |
| @@ -223,7 +226,9 @@ struct SurfaceParams { | |||
| 223 | // gamma. | 226 | // gamma. |
| 224 | case Tegra::RenderTargetFormat::RGBA8_SRGB: | 227 | case Tegra::RenderTargetFormat::RGBA8_SRGB: |
| 225 | case Tegra::RenderTargetFormat::RGBA8_UNORM: | 228 | case Tegra::RenderTargetFormat::RGBA8_UNORM: |
| 226 | return PixelFormat::ABGR8; | 229 | return PixelFormat::ABGR8U; |
| 230 | case Tegra::RenderTargetFormat::RGBA8_SNORM: | ||
| 231 | return PixelFormat::ABGR8S; | ||
| 227 | case Tegra::RenderTargetFormat::BGRA8_UNORM: | 232 | case Tegra::RenderTargetFormat::BGRA8_UNORM: |
| 228 | return PixelFormat::BGRA8; | 233 | return PixelFormat::BGRA8; |
| 229 | case Tegra::RenderTargetFormat::RGB10_A2_UNORM: | 234 | case Tegra::RenderTargetFormat::RGB10_A2_UNORM: |
| @@ -275,7 +280,15 @@ struct SurfaceParams { | |||
| 275 | // TODO(Subv): Properly implement this | 280 | // TODO(Subv): Properly implement this |
| 276 | switch (format) { | 281 | switch (format) { |
| 277 | case Tegra::Texture::TextureFormat::A8R8G8B8: | 282 | case Tegra::Texture::TextureFormat::A8R8G8B8: |
| 278 | return PixelFormat::ABGR8; | 283 | switch (component_type) { |
| 284 | case Tegra::Texture::ComponentType::UNORM: | ||
| 285 | return PixelFormat::ABGR8U; | ||
| 286 | case Tegra::Texture::ComponentType::SNORM: | ||
| 287 | return PixelFormat::ABGR8S; | ||
| 288 | } | ||
| 289 | LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", | ||
| 290 | static_cast<u32>(component_type)); | ||
| 291 | UNREACHABLE(); | ||
| 279 | case Tegra::Texture::TextureFormat::B5G6R5: | 292 | case Tegra::Texture::TextureFormat::B5G6R5: |
| 280 | return PixelFormat::B5G6R5; | 293 | return PixelFormat::B5G6R5; |
| 281 | case Tegra::Texture::TextureFormat::A2B10G10R10: | 294 | case Tegra::Texture::TextureFormat::A2B10G10R10: |
| @@ -402,6 +415,7 @@ struct SurfaceParams { | |||
| 402 | case Tegra::RenderTargetFormat::R16_UNORM: | 415 | case Tegra::RenderTargetFormat::R16_UNORM: |
| 403 | case Tegra::RenderTargetFormat::B5G6R5_UNORM: | 416 | case Tegra::RenderTargetFormat::B5G6R5_UNORM: |
| 404 | return ComponentType::UNorm; | 417 | return ComponentType::UNorm; |
| 418 | case Tegra::RenderTargetFormat::RGBA8_SNORM: | ||
| 405 | case Tegra::RenderTargetFormat::RG16_SNORM: | 419 | case Tegra::RenderTargetFormat::RG16_SNORM: |
| 406 | case Tegra::RenderTargetFormat::R16_SNORM: | 420 | case Tegra::RenderTargetFormat::R16_SNORM: |
| 407 | return ComponentType::SNorm; | 421 | return ComponentType::SNorm; |
| @@ -429,7 +443,7 @@ struct SurfaceParams { | |||
| 429 | static PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { | 443 | static PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { |
| 430 | switch (format) { | 444 | switch (format) { |
| 431 | case Tegra::FramebufferConfig::PixelFormat::ABGR8: | 445 | case Tegra::FramebufferConfig::PixelFormat::ABGR8: |
| 432 | return PixelFormat::ABGR8; | 446 | return PixelFormat::ABGR8U; |
| 433 | default: | 447 | default: |
| 434 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | 448 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); |
| 435 | UNREACHABLE(); | 449 | UNREACHABLE(); |