Common.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #pragma once
  6. //
  7. // Macros & functions C++
  8. //
  9. #if defined(__cplusplus)
  10. # include <AnKi/Math.h>
  11. # define ANKI_BEGIN_NAMESPACE \
  12. namespace anki \
  13. {
  14. # define ANKI_END_NAMESPACE }
  15. # define ANKI_SHADER_FUNC_INLINE inline
  16. # define ANKI_SHADER_INOUT(type_) type_&
  17. # define ANKI_SHADER_IN(type_) const type_&
  18. # define ANKI_SHADER_OUT(type_) type_&
  19. # define ANKI_SHADER_STATIC_ASSERT(cond_) static_assert(cond_, "See file")
  20. # define ANKI_SIZEOF(x) sizeof(x)
  21. ANKI_BEGIN_NAMESPACE
  22. template<typename T>
  23. inline F32 dot(const T& a, const T& b)
  24. {
  25. return a.dot(b);
  26. }
  27. using Address = U64;
  28. ANKI_END_NAMESPACE
  29. # define ANKI_CPP_CODE(x) x
  30. //
  31. // Macros & functions GLSL
  32. //
  33. #else
  34. # define x() x
  35. # define y() y
  36. # define z() z
  37. # define w() w
  38. # define xyz() xyz
  39. # define ANKI_BEGIN_NAMESPACE
  40. # define ANKI_END_NAMESPACE
  41. # define ANKI_SHADER_FUNC_INLINE
  42. # define ANKI_SHADER_INOUT(type_) inout type_
  43. # define ANKI_SHADER_IN(type_) in type_
  44. # define ANKI_SHADER_OUT(type_) out type_
  45. # define ANKI_SHADER_STATIC_ASSERT(cond_)
  46. # define ANKI_CPP_CODE(x)
  47. #endif
  48. //
  49. // Various
  50. //
  51. ANKI_BEGIN_NAMESPACE
  52. /// The renderer will group drawcalls into instances up to this number.
  53. const U32 MAX_INSTANCE_COUNT = 64u;
  54. const U32 MAX_LOD_COUNT = 3u;
  55. ANKI_END_NAMESPACE