decoders.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <vector>
  6. #include "common/common_types.h"
  7. #include "video_core/textures/texture.h"
  8. namespace Tegra::Texture {
  9. // GOBSize constant. Calculated by 64 bytes in x multiplied by 8 y coords, represents
  10. // an small rect of (64/bytes_per_pixel)X8.
  11. inline std::size_t GetGOBSize() {
  12. return 512;
  13. }
  14. /// Unswizzles a swizzled texture without changing its format.
  15. void UnswizzleTexture(u8* unswizzled_data, VAddr address, u32 tile_size_x, u32 tile_size_y,
  16. u32 bytes_per_pixel, u32 width, u32 height, u32 depth,
  17. u32 block_height = TICEntry::DefaultBlockHeight,
  18. u32 block_depth = TICEntry::DefaultBlockHeight, u32 width_spacing = 0);
  19. /// Unswizzles a swizzled texture without changing its format.
  20. std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y,
  21. u32 bytes_per_pixel, u32 width, u32 height, u32 depth,
  22. u32 block_height = TICEntry::DefaultBlockHeight,
  23. u32 block_depth = TICEntry::DefaultBlockHeight,
  24. u32 width_spacing = 0);
  25. /// Copies texture data from a buffer and performs swizzling/unswizzling as necessary.
  26. void CopySwizzledData(u32 width, u32 height, u32 depth, u32 bytes_per_pixel,
  27. u32 out_bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data,
  28. bool unswizzle, u32 block_height, u32 block_depth, u32 width_spacing);
  29. /// Decodes an unswizzled texture into a A8R8G8B8 texture.
  30. std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat format, u32 width,
  31. u32 height);
  32. /// This function calculates the correct size of a texture depending if it's tiled or not.
  33. std::size_t CalculateSize(bool tiled, u32 bytes_per_pixel, u32 width, u32 height, u32 depth,
  34. u32 block_height, u32 block_depth);
  35. /// Copies an untiled subrectangle into a tiled surface.
  36. void SwizzleSubrect(u32 subrect_width, u32 subrect_height, u32 source_pitch, u32 swizzled_width,
  37. u32 bytes_per_pixel, VAddr swizzled_data, VAddr unswizzled_data,
  38. u32 block_height);
  39. /// Copies a tiled subrectangle into a linear surface.
  40. void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32 swizzled_width,
  41. u32 bytes_per_pixel, VAddr swizzled_data, VAddr unswizzled_data,
  42. u32 block_height, u32 offset_x, u32 offset_y);
  43. } // namespace Tegra::Texture