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.cpp236
1 files changed, 0 insertions, 236 deletions
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index 20bcda6bc..1655ccf16 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -168,242 +168,6 @@ PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format)
168 } 168 }
169} 169}
170 170
171PixelFormat 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
407PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { 171PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) {
408 switch (format) { 172 switch (format) {
409 case Tegra::FramebufferConfig::PixelFormat::ABGR8: 173 case Tegra::FramebufferConfig::PixelFormat::ABGR8: