decoders.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. /**
  15. * Unswizzles a swizzled texture without changing its format.
  16. */
  17. std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y,
  18. u32 bytes_per_pixel, u32 width, u32 height, u32 depth,
  19. u32 block_height = TICEntry::DefaultBlockHeight,
  20. u32 block_depth = TICEntry::DefaultBlockHeight);
  21. /// Copies texture data from a buffer and performs swizzling/unswizzling as necessary.
  22. void CopySwizzledData(u32 width, u32 height, u32 depth, u32 bytes_per_pixel,
  23. u32 out_bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data,
  24. bool unswizzle, u32 block_height, u32 block_depth);
  25. /**
  26. * Decodes an unswizzled texture into a A8R8G8B8 texture.
  27. */
  28. std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat format, u32 width,
  29. u32 height);
  30. /**
  31. * This function calculates the correct size of a texture depending if it's tiled or not.
  32. */
  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