Common.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. {
  8. Array<CString, U(GpuVendor::COUNT)> GPU_VENDOR_STR = {"UNKNOWN", "ARM", "NVIDIA", "AMD", "INTEL"};
  9. PtrSize computeSurfaceSize(U32 width32, U32 height32, Format fmt)
  10. {
  11. const PtrSize width = width32;
  12. const PtrSize height = height32;
  13. ANKI_ASSERT(width > 0 && height > 0);
  14. ANKI_ASSERT(fmt != Format::NONE);
  15. const FormatInfo inf = getFormatInfo(fmt);
  16. if(inf.m_blockSize > 0)
  17. {
  18. // Compressed
  19. ANKI_ASSERT((width % inf.m_blockWidth) == 0);
  20. ANKI_ASSERT((height % inf.m_blockHeight) == 0);
  21. return (width / inf.m_blockWidth) * (height / inf.m_blockHeight) * inf.m_blockSize;
  22. }
  23. else
  24. {
  25. return width * height * inf.m_texelSize;
  26. }
  27. }
  28. PtrSize computeVolumeSize(U32 width32, U32 height32, U32 depth32, Format fmt)
  29. {
  30. const PtrSize width = width32;
  31. const PtrSize height = height32;
  32. const PtrSize depth = depth32;
  33. ANKI_ASSERT(width > 0 && height > 0 && depth > 0);
  34. ANKI_ASSERT(fmt != Format::NONE);
  35. const FormatInfo inf = getFormatInfo(fmt);
  36. if(inf.m_blockSize > 0)
  37. {
  38. // Compressed
  39. ANKI_ASSERT((width % inf.m_blockWidth) == 0);
  40. ANKI_ASSERT((height % inf.m_blockHeight) == 0);
  41. return (width / inf.m_blockWidth) * (height / inf.m_blockHeight) * inf.m_blockSize * depth;
  42. }
  43. else
  44. {
  45. return width * height * depth * inf.m_texelSize;
  46. }
  47. }
  48. } // end namespace anki