Common.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Gr/Common.h>
  6. namespace anki {
  7. Array<CString, U(GpuVendor::COUNT)> GPU_VENDOR_STR = {"UNKNOWN", "ARM", "NVIDIA", "AMD", "INTEL"};
  8. PtrSize computeSurfaceSize(U32 width32, U32 height32, Format fmt)
  9. {
  10. const PtrSize width = width32;
  11. const PtrSize height = height32;
  12. ANKI_ASSERT(width > 0 && height > 0);
  13. ANKI_ASSERT(fmt != Format::NONE);
  14. const FormatInfo inf = getFormatInfo(fmt);
  15. if(inf.m_blockSize > 0)
  16. {
  17. // Compressed
  18. ANKI_ASSERT((width % inf.m_blockWidth) == 0);
  19. ANKI_ASSERT((height % inf.m_blockHeight) == 0);
  20. return (width / inf.m_blockWidth) * (height / inf.m_blockHeight) * inf.m_blockSize;
  21. }
  22. else
  23. {
  24. return width * height * inf.m_texelSize;
  25. }
  26. }
  27. PtrSize computeVolumeSize(U32 width32, U32 height32, U32 depth32, Format fmt)
  28. {
  29. const PtrSize width = width32;
  30. const PtrSize height = height32;
  31. const PtrSize depth = depth32;
  32. ANKI_ASSERT(width > 0 && height > 0 && depth > 0);
  33. ANKI_ASSERT(fmt != Format::NONE);
  34. const FormatInfo inf = getFormatInfo(fmt);
  35. if(inf.m_blockSize > 0)
  36. {
  37. // Compressed
  38. ANKI_ASSERT((width % inf.m_blockWidth) == 0);
  39. ANKI_ASSERT((height % inf.m_blockHeight) == 0);
  40. return (width / inf.m_blockWidth) * (height / inf.m_blockHeight) * inf.m_blockSize * depth;
  41. }
  42. else
  43. {
  44. return width * height * depth * inf.m_texelSize;
  45. }
  46. }
  47. } // end namespace anki