summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2018-07-23 20:13:19 -0700
committerGravatar GitHub2018-07-23 20:13:19 -0700
commit1ff3bea6c73dc9094b557b1828e33620e3c1a6ca (patch)
treed35c2ef0cc03cd2e8e066f4244811273d2b92885
parentMerge pull request #792 from lioncash/retval (diff)
parentgl_rasterizer_cache: Implement RenderTargetFormat RG32_FLOAT. (diff)
downloadyuzu-1ff3bea6c73dc9094b557b1828e33620e3c1a6ca.tar.gz
yuzu-1ff3bea6c73dc9094b557b1828e33620e3c1a6ca.tar.xz
yuzu-1ff3bea6c73dc9094b557b1828e33620e3c1a6ca.zip
Merge pull request #791 from bunnei/rg32f-rgba32f-bgra8
gl_rasterizer_cache: Implement formats BGRA8_UNORM/RGBA32_FLOAT/RG32_FLOAT
-rw-r--r--src/video_core/gpu.cpp2
-rw-r--r--src/video_core/gpu.h2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp18
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h56
-rw-r--r--src/video_core/textures/decoders.cpp4
5 files changed, 70 insertions, 12 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index a003bc9e3..60c49d672 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -35,9 +35,11 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) {
35 case RenderTargetFormat::RGBA32_FLOAT: 35 case RenderTargetFormat::RGBA32_FLOAT:
36 return 16; 36 return 16;
37 case RenderTargetFormat::RGBA16_FLOAT: 37 case RenderTargetFormat::RGBA16_FLOAT:
38 case RenderTargetFormat::RG32_FLOAT:
38 return 8; 39 return 8;
39 case RenderTargetFormat::RGBA8_UNORM: 40 case RenderTargetFormat::RGBA8_UNORM:
40 case RenderTargetFormat::RGB10_A2_UNORM: 41 case RenderTargetFormat::RGB10_A2_UNORM:
42 case RenderTargetFormat::BGRA8_UNORM:
41 return 4; 43 return 4;
42 default: 44 default:
43 UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format)); 45 UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format));
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index a32148ecd..58501ca8b 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -18,6 +18,8 @@ enum class RenderTargetFormat : u32 {
18 RGBA32_FLOAT = 0xC0, 18 RGBA32_FLOAT = 0xC0,
19 RGBA32_UINT = 0xC2, 19 RGBA32_UINT = 0xC2,
20 RGBA16_FLOAT = 0xCA, 20 RGBA16_FLOAT = 0xCA,
21 RG32_FLOAT = 0xCB,
22 BGRA8_UNORM = 0xCF,
21 RGB10_A2_UNORM = 0xD1, 23 RGB10_A2_UNORM = 0xD1,
22 RGBA8_UNORM = 0xD5, 24 RGBA8_UNORM = 0xD5,
23 RGBA8_SRGB = 0xD6, 25 RGBA8_SRGB = 0xD6,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 28f0bc379..8f99864a0 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -38,7 +38,8 @@ struct FormatTuple {
38 params.addr = config.tic.Address(); 38 params.addr = config.tic.Address();
39 params.is_tiled = config.tic.IsTiled(); 39 params.is_tiled = config.tic.IsTiled();
40 params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0, 40 params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0,
41 params.pixel_format = PixelFormatFromTextureFormat(config.tic.format); 41 params.pixel_format =
42 PixelFormatFromTextureFormat(config.tic.format, config.tic.r_type.Value());
42 params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value()); 43 params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value());
43 params.type = GetFormatType(params.pixel_format); 44 params.type = GetFormatType(params.pixel_format);
44 params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format)); 45 params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format));
@@ -106,6 +107,9 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
106 true}, // BC7U 107 true}, // BC7U
107 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 108 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
108 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8 109 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8
110 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
111 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F
112 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F
109 113
110 // DepthStencil formats 114 // DepthStencil formats
111 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, 115 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm,
@@ -197,9 +201,10 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
197 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, 201 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
198 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, 202 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
199 MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, 203 MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
200 MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::Z24S8>, 204 MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>,
201 MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, 205 MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>,
202 MortonCopy<true, PixelFormat::Z16>, 206 MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>,
207 MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>,
203}; 208};
204 209
205static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), 210static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@@ -213,7 +218,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
213 MortonCopy<false, PixelFormat::RGBA16F>, 218 MortonCopy<false, PixelFormat::RGBA16F>,
214 MortonCopy<false, PixelFormat::R11FG11FB10F>, 219 MortonCopy<false, PixelFormat::R11FG11FB10F>,
215 MortonCopy<false, PixelFormat::RGBA32UI>, 220 MortonCopy<false, PixelFormat::RGBA32UI>,
216 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1/BC7U formats is not yet supported 221 // TODO(Subv): Swizzling DXT1/DXT23/DXT45/DXN1/BC7U/ASTC_2D_4X4 formats is not supported
217 nullptr, 222 nullptr,
218 nullptr, 223 nullptr,
219 nullptr, 224 nullptr,
@@ -221,6 +226,9 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
221 nullptr, 226 nullptr,
222 nullptr, 227 nullptr,
223 MortonCopy<false, PixelFormat::G8R8>, 228 MortonCopy<false, PixelFormat::G8R8>,
229 MortonCopy<false, PixelFormat::BGRA8>,
230 MortonCopy<false, PixelFormat::RGBA32F>,
231 MortonCopy<false, PixelFormat::RG32F>,
224 MortonCopy<false, PixelFormat::Z24S8>, 232 MortonCopy<false, PixelFormat::Z24S8>,
225 MortonCopy<false, PixelFormat::S8Z24>, 233 MortonCopy<false, PixelFormat::S8Z24>,
226 MortonCopy<false, PixelFormat::Z32F>, 234 MortonCopy<false, PixelFormat::Z32F>,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index b084c4db4..23efbe67c 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -37,14 +37,17 @@ struct SurfaceParams {
37 BC7U = 12, 37 BC7U = 12,
38 ASTC_2D_4X4 = 13, 38 ASTC_2D_4X4 = 13,
39 G8R8 = 14, 39 G8R8 = 14,
40 BGRA8 = 15,
41 RGBA32F = 16,
42 RG32F = 17,
40 43
41 MaxColorFormat, 44 MaxColorFormat,
42 45
43 // DepthStencil formats 46 // DepthStencil formats
44 Z24S8 = 15, 47 Z24S8 = 18,
45 S8Z24 = 16, 48 S8Z24 = 19,
46 Z32F = 17, 49 Z32F = 20,
47 Z16 = 18, 50 Z16 = 21,
48 51
49 MaxDepthStencilFormat, 52 MaxDepthStencilFormat,
50 53
@@ -97,6 +100,9 @@ struct SurfaceParams {
97 4, // BC7U 100 4, // BC7U
98 4, // ASTC_2D_4X4 101 4, // ASTC_2D_4X4
99 1, // G8R8 102 1, // G8R8
103 1, // BGRA8
104 1, // RGBA32F
105 1, // RG32F
100 1, // Z24S8 106 1, // Z24S8
101 1, // S8Z24 107 1, // S8Z24
102 1, // Z32F 108 1, // Z32F
@@ -127,6 +133,9 @@ struct SurfaceParams {
127 128, // BC7U 133 128, // BC7U
128 32, // ASTC_2D_4X4 134 32, // ASTC_2D_4X4
129 16, // G8R8 135 16, // G8R8
136 32, // BGRA8
137 128, // RGBA32F
138 64, // RG32F
130 32, // Z24S8 139 32, // Z24S8
131 32, // S8Z24 140 32, // S8Z24
132 32, // Z32F 141 32, // Z32F
@@ -162,10 +171,16 @@ struct SurfaceParams {
162 case Tegra::RenderTargetFormat::RGBA8_UNORM: 171 case Tegra::RenderTargetFormat::RGBA8_UNORM:
163 case Tegra::RenderTargetFormat::RGBA8_SRGB: 172 case Tegra::RenderTargetFormat::RGBA8_SRGB:
164 return PixelFormat::ABGR8; 173 return PixelFormat::ABGR8;
174 case Tegra::RenderTargetFormat::BGRA8_UNORM:
175 return PixelFormat::BGRA8;
165 case Tegra::RenderTargetFormat::RGB10_A2_UNORM: 176 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
166 return PixelFormat::A2B10G10R10; 177 return PixelFormat::A2B10G10R10;
167 case Tegra::RenderTargetFormat::RGBA16_FLOAT: 178 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
168 return PixelFormat::RGBA16F; 179 return PixelFormat::RGBA16F;
180 case Tegra::RenderTargetFormat::RGBA32_FLOAT:
181 return PixelFormat::RGBA32F;
182 case Tegra::RenderTargetFormat::RG32_FLOAT:
183 return PixelFormat::RG32F;
169 case Tegra::RenderTargetFormat::R11G11B10_FLOAT: 184 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
170 return PixelFormat::R11FG11FB10F; 185 return PixelFormat::R11FG11FB10F;
171 case Tegra::RenderTargetFormat::RGBA32_UINT: 186 case Tegra::RenderTargetFormat::RGBA32_UINT:
@@ -176,7 +191,8 @@ struct SurfaceParams {
176 } 191 }
177 } 192 }
178 193
179 static PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format) { 194 static PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
195 Tegra::Texture::ComponentType component_type) {
180 // TODO(Subv): Properly implement this 196 // TODO(Subv): Properly implement this
181 switch (format) { 197 switch (format) {
182 case Tegra::Texture::TextureFormat::A8R8G8B8: 198 case Tegra::Texture::TextureFormat::A8R8G8B8:
@@ -196,7 +212,17 @@ struct SurfaceParams {
196 case Tegra::Texture::TextureFormat::BF10GF11RF11: 212 case Tegra::Texture::TextureFormat::BF10GF11RF11:
197 return PixelFormat::R11FG11FB10F; 213 return PixelFormat::R11FG11FB10F;
198 case Tegra::Texture::TextureFormat::R32_G32_B32_A32: 214 case Tegra::Texture::TextureFormat::R32_G32_B32_A32:
199 return PixelFormat::RGBA32UI; 215 switch (component_type) {
216 case Tegra::Texture::ComponentType::FLOAT:
217 return PixelFormat::RGBA32F;
218 case Tegra::Texture::ComponentType::UINT:
219 return PixelFormat::RGBA32UI;
220 }
221 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
222 static_cast<u32>(component_type));
223 UNREACHABLE();
224 case Tegra::Texture::TextureFormat::R32_G32:
225 return PixelFormat::RG32F;
200 case Tegra::Texture::TextureFormat::DXT1: 226 case Tegra::Texture::TextureFormat::DXT1:
201 return PixelFormat::DXT1; 227 return PixelFormat::DXT1;
202 case Tegra::Texture::TextureFormat::DXT23: 228 case Tegra::Texture::TextureFormat::DXT23:
@@ -210,7 +236,8 @@ struct SurfaceParams {
210 case Tegra::Texture::TextureFormat::ASTC_2D_4X4: 236 case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
211 return PixelFormat::ASTC_2D_4X4; 237 return PixelFormat::ASTC_2D_4X4;
212 default: 238 default:
213 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 239 LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}",
240 static_cast<u32>(format), static_cast<u32>(component_type));
214 UNREACHABLE(); 241 UNREACHABLE();
215 } 242 }
216 } 243 }
@@ -248,7 +275,16 @@ struct SurfaceParams {
248 return Tegra::Texture::TextureFormat::BC7U; 275 return Tegra::Texture::TextureFormat::BC7U;
249 case PixelFormat::ASTC_2D_4X4: 276 case PixelFormat::ASTC_2D_4X4:
250 return Tegra::Texture::TextureFormat::ASTC_2D_4X4; 277 return Tegra::Texture::TextureFormat::ASTC_2D_4X4;
278 case PixelFormat::BGRA8:
279 // TODO(bunnei): This is fine for unswizzling (since we just need the right component
280 // sizes), but could be a bug if we used this function in different ways.
281 return Tegra::Texture::TextureFormat::A8R8G8B8;
282 case PixelFormat::RGBA32F:
283 return Tegra::Texture::TextureFormat::R32_G32_B32_A32;
284 case PixelFormat::RG32F:
285 return Tegra::Texture::TextureFormat::R32_G32;
251 default: 286 default:
287 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
252 UNREACHABLE(); 288 UNREACHABLE();
253 } 289 }
254 } 290 }
@@ -264,6 +300,7 @@ struct SurfaceParams {
264 case PixelFormat::Z16: 300 case PixelFormat::Z16:
265 return Tegra::DepthFormat::Z16_UNORM; 301 return Tegra::DepthFormat::Z16_UNORM;
266 default: 302 default:
303 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
267 UNREACHABLE(); 304 UNREACHABLE();
268 } 305 }
269 } 306 }
@@ -273,6 +310,8 @@ struct SurfaceParams {
273 switch (type) { 310 switch (type) {
274 case Tegra::Texture::ComponentType::UNORM: 311 case Tegra::Texture::ComponentType::UNORM:
275 return ComponentType::UNorm; 312 return ComponentType::UNorm;
313 case Tegra::Texture::ComponentType::FLOAT:
314 return ComponentType::Float;
276 default: 315 default:
277 LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type)); 316 LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type));
278 UNREACHABLE(); 317 UNREACHABLE();
@@ -284,10 +323,13 @@ struct SurfaceParams {
284 switch (format) { 323 switch (format) {
285 case Tegra::RenderTargetFormat::RGBA8_UNORM: 324 case Tegra::RenderTargetFormat::RGBA8_UNORM:
286 case Tegra::RenderTargetFormat::RGBA8_SRGB: 325 case Tegra::RenderTargetFormat::RGBA8_SRGB:
326 case Tegra::RenderTargetFormat::BGRA8_UNORM:
287 case Tegra::RenderTargetFormat::RGB10_A2_UNORM: 327 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
288 return ComponentType::UNorm; 328 return ComponentType::UNorm;
289 case Tegra::RenderTargetFormat::RGBA16_FLOAT: 329 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
290 case Tegra::RenderTargetFormat::R11G11B10_FLOAT: 330 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
331 case Tegra::RenderTargetFormat::RGBA32_FLOAT:
332 case Tegra::RenderTargetFormat::RG32_FLOAT:
291 return ComponentType::Float; 333 return ComponentType::Float;
292 case Tegra::RenderTargetFormat::RGBA32_UINT: 334 case Tegra::RenderTargetFormat::RGBA32_UINT:
293 return ComponentType::UInt; 335 return ComponentType::UInt;
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index a3e67d105..e5e9e1898 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -72,6 +72,8 @@ u32 BytesPerPixel(TextureFormat format) {
72 return 8; 72 return 8;
73 case TextureFormat::R32_G32_B32_A32: 73 case TextureFormat::R32_G32_B32_A32:
74 return 16; 74 return 16;
75 case TextureFormat::R32_G32:
76 return 8;
75 default: 77 default:
76 UNIMPLEMENTED_MSG("Format not implemented"); 78 UNIMPLEMENTED_MSG("Format not implemented");
77 break; 79 break;
@@ -118,6 +120,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
118 case TextureFormat::G8R8: 120 case TextureFormat::G8R8:
119 case TextureFormat::R16_G16_B16_A16: 121 case TextureFormat::R16_G16_B16_A16:
120 case TextureFormat::R32_G32_B32_A32: 122 case TextureFormat::R32_G32_B32_A32:
123 case TextureFormat::R32_G32:
121 case TextureFormat::BF10GF11RF11: 124 case TextureFormat::BF10GF11RF11:
122 case TextureFormat::ASTC_2D_4X4: 125 case TextureFormat::ASTC_2D_4X4:
123 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, 126 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
@@ -174,6 +177,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
174 case TextureFormat::G8R8: 177 case TextureFormat::G8R8:
175 case TextureFormat::BF10GF11RF11: 178 case TextureFormat::BF10GF11RF11:
176 case TextureFormat::R32_G32_B32_A32: 179 case TextureFormat::R32_G32_B32_A32:
180 case TextureFormat::R32_G32:
177 // TODO(Subv): For the time being just forward the same data without any decoding. 181 // TODO(Subv): For the time being just forward the same data without any decoding.
178 rgba_data = texture_data; 182 rgba_data = texture_data;
179 break; 183 break;