summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-06-05 21:57:16 -0500
committerGravatar Subv2018-06-05 21:57:16 -0500
commitc531a92edaae409275d9e7309d7b315d6fccf190 (patch)
treee3a14bf936375514f99485b68b1dce05d377c93d /src
parentGPU: Fixed the compression factor for RGBA16F textures. (diff)
downloadyuzu-c531a92edaae409275d9e7309d7b315d6fccf190.tar.gz
yuzu-c531a92edaae409275d9e7309d7b315d6fccf190.tar.xz
yuzu-c531a92edaae409275d9e7309d7b315d6fccf190.zip
GPU: Implemented the R11FG11FB10F texture and rendertarget formats.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/gpu.h1
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp19
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h18
-rw-r--r--src/video_core/textures/decoders.cpp3
4 files changed, 30 insertions, 11 deletions
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index f168a5171..2762a22ec 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -19,6 +19,7 @@ enum class RenderTargetFormat : u32 {
19 RGB10_A2_UNORM = 0xD1, 19 RGB10_A2_UNORM = 0xD1,
20 RGBA8_UNORM = 0xD5, 20 RGBA8_UNORM = 0xD5,
21 RGBA8_SRGB = 0xD6, 21 RGBA8_SRGB = 0xD6,
22 R11G11B10_FLOAT = 0xE0,
22}; 23};
23 24
24/// Returns the number of bytes per pixel of each rendertarget format. 25/// Returns the number of bytes per pixel of each rendertarget format.
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index d6048f639..9164d7f34 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -50,6 +50,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
50 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5 50 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5
51 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, false}, // R8 51 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, false}, // R8
52 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, false}, // RGBA16F 52 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, false}, // RGBA16F
53 {GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, false}, // R11FG11FB10F
53 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1 54 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1
54 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23 55 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23
55 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45 56 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45
@@ -60,8 +61,10 @@ static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType
60 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format); 61 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format);
61 if (type == SurfaceType::ColorTexture) { 62 if (type == SurfaceType::ColorTexture) {
62 ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size()); 63 ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size());
63 // For now only UNORM components are supported, or RGBA16F which is type FLOAT 64 // For now only UNORM components are supported, or either R11FG11FB10F or RGBA16F which are
64 ASSERT(component_type == ComponentType::UNorm || pixel_format == PixelFormat::RGBA16F); 65 // type FLOAT
66 ASSERT(component_type == ComponentType::UNorm || pixel_format == PixelFormat::RGBA16F ||
67 pixel_format == PixelFormat::R11FG11FB10F);
65 return tex_format_tuples[static_cast<unsigned int>(pixel_format)]; 68 return tex_format_tuples[static_cast<unsigned int>(pixel_format)];
66 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) { 69 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) {
67 // TODO(Subv): Implement depth formats 70 // TODO(Subv): Implement depth formats
@@ -110,11 +113,12 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
110 Tegra::GPUVAddr), 113 Tegra::GPUVAddr),
111 SurfaceParams::MaxPixelFormat> 114 SurfaceParams::MaxPixelFormat>
112 morton_to_gl_fns = { 115 morton_to_gl_fns = {
113 MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>, 116 MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>,
114 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>, 117 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>,
115 MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>, 118 MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>,
116 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, 119 MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::DXT1>,
117 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, 120 MortonCopy<true, PixelFormat::DXT23>, MortonCopy<true, PixelFormat::DXT45>,
121 MortonCopy<true, PixelFormat::DXN1>,
118}; 122};
119 123
120static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr, 124static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr,
@@ -127,6 +131,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
127 MortonCopy<false, PixelFormat::A1B5G5R5>, 131 MortonCopy<false, PixelFormat::A1B5G5R5>,
128 MortonCopy<false, PixelFormat::R8>, 132 MortonCopy<false, PixelFormat::R8>,
129 MortonCopy<false, PixelFormat::RGBA16F>, 133 MortonCopy<false, PixelFormat::RGBA16F>,
134 MortonCopy<false, PixelFormat::R11FG11FB10F>,
130 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1 formats is not yet supported 135 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1 formats is not yet supported
131 nullptr, 136 nullptr,
132 nullptr, 137 nullptr,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index f9735ba71..0f43e863d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -60,10 +60,11 @@ struct SurfaceParams {
60 A1B5G5R5 = 3, 60 A1B5G5R5 = 3,
61 R8 = 4, 61 R8 = 4,
62 RGBA16F = 5, 62 RGBA16F = 5,
63 DXT1 = 6, 63 R11FG11FB10F = 6,
64 DXT23 = 7, 64 DXT1 = 7,
65 DXT45 = 8, 65 DXT23 = 8,
66 DXN1 = 9, // This is also known as BC4 66 DXT45 = 9,
67 DXN1 = 10, // This is also known as BC4
67 68
68 Max, 69 Max,
69 Invalid = 255, 70 Invalid = 255,
@@ -105,6 +106,7 @@ struct SurfaceParams {
105 1, // A1B5G5R5 106 1, // A1B5G5R5
106 1, // R8 107 1, // R8
107 1, // RGBA16F 108 1, // RGBA16F
109 1, // R11FG11FB10F
108 4, // DXT1 110 4, // DXT1
109 4, // DXT23 111 4, // DXT23
110 4, // DXT45 112 4, // DXT45
@@ -129,6 +131,7 @@ struct SurfaceParams {
129 16, // A1B5G5R5 131 16, // A1B5G5R5
130 8, // R8 132 8, // R8
131 64, // RGBA16F 133 64, // RGBA16F
134 32, // R11FG11FB10F
132 64, // DXT1 135 64, // DXT1
133 128, // DXT23 136 128, // DXT23
134 128, // DXT45 137 128, // DXT45
@@ -151,6 +154,8 @@ struct SurfaceParams {
151 return PixelFormat::A2B10G10R10; 154 return PixelFormat::A2B10G10R10;
152 case Tegra::RenderTargetFormat::RGBA16_FLOAT: 155 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
153 return PixelFormat::RGBA16F; 156 return PixelFormat::RGBA16F;
157 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
158 return PixelFormat::R11FG11FB10F;
154 default: 159 default:
155 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 160 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
156 UNREACHABLE(); 161 UNREACHABLE();
@@ -182,6 +187,8 @@ struct SurfaceParams {
182 return PixelFormat::R8; 187 return PixelFormat::R8;
183 case Tegra::Texture::TextureFormat::R16_G16_B16_A16: 188 case Tegra::Texture::TextureFormat::R16_G16_B16_A16:
184 return PixelFormat::RGBA16F; 189 return PixelFormat::RGBA16F;
190 case Tegra::Texture::TextureFormat::BF10GF11RF11:
191 return PixelFormat::R11FG11FB10F;
185 case Tegra::Texture::TextureFormat::DXT1: 192 case Tegra::Texture::TextureFormat::DXT1:
186 return PixelFormat::DXT1; 193 return PixelFormat::DXT1;
187 case Tegra::Texture::TextureFormat::DXT23: 194 case Tegra::Texture::TextureFormat::DXT23:
@@ -211,6 +218,8 @@ struct SurfaceParams {
211 return Tegra::Texture::TextureFormat::R8; 218 return Tegra::Texture::TextureFormat::R8;
212 case PixelFormat::RGBA16F: 219 case PixelFormat::RGBA16F:
213 return Tegra::Texture::TextureFormat::R16_G16_B16_A16; 220 return Tegra::Texture::TextureFormat::R16_G16_B16_A16;
221 case PixelFormat::R11FG11FB10F:
222 return Tegra::Texture::TextureFormat::BF10GF11RF11;
214 case PixelFormat::DXT1: 223 case PixelFormat::DXT1:
215 return Tegra::Texture::TextureFormat::DXT1; 224 return Tegra::Texture::TextureFormat::DXT1;
216 case PixelFormat::DXT23: 225 case PixelFormat::DXT23:
@@ -243,6 +252,7 @@ struct SurfaceParams {
243 case Tegra::RenderTargetFormat::RGB10_A2_UNORM: 252 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
244 return ComponentType::UNorm; 253 return ComponentType::UNorm;
245 case Tegra::RenderTargetFormat::RGBA16_FLOAT: 254 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
255 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
246 return ComponentType::Float; 256 return ComponentType::Float;
247 default: 257 default:
248 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 258 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 2d2af5554..7bf9c4c4b 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -55,6 +55,7 @@ u32 BytesPerPixel(TextureFormat format) {
55 return 16; 55 return 16;
56 case TextureFormat::A8R8G8B8: 56 case TextureFormat::A8R8G8B8:
57 case TextureFormat::A2B10G10R10: 57 case TextureFormat::A2B10G10R10:
58 case TextureFormat::BF10GF11RF11:
58 return 4; 59 return 4;
59 case TextureFormat::A1B5G5R5: 60 case TextureFormat::A1B5G5R5:
60 case TextureFormat::B5G6R5: 61 case TextureFormat::B5G6R5:
@@ -92,6 +93,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
92 case TextureFormat::B5G6R5: 93 case TextureFormat::B5G6R5:
93 case TextureFormat::R8: 94 case TextureFormat::R8:
94 case TextureFormat::R16_G16_B16_A16: 95 case TextureFormat::R16_G16_B16_A16:
96 case TextureFormat::BF10GF11RF11:
95 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, 97 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
96 unswizzled_data.data(), true, block_height); 98 unswizzled_data.data(), true, block_height);
97 break; 99 break;
@@ -118,6 +120,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
118 case TextureFormat::A1B5G5R5: 120 case TextureFormat::A1B5G5R5:
119 case TextureFormat::B5G6R5: 121 case TextureFormat::B5G6R5:
120 case TextureFormat::R8: 122 case TextureFormat::R8:
123 case TextureFormat::BF10GF11RF11:
121 // TODO(Subv): For the time being just forward the same data without any decoding. 124 // TODO(Subv): For the time being just forward the same data without any decoding.
122 rgba_data = texture_data; 125 rgba_data = texture_data;
123 break; 126 break;