Functions.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2009-present, 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. #include <AnKi/Gr/BackendCommon/Common.h>
  7. #include <AnKi/Math.h>
  8. namespace anki {
  9. inline Bool stencilTestDisabled(StencilOperation stencilFail, StencilOperation stencilPassDepthFail, StencilOperation stencilPassDepthPass,
  10. CompareOperation compare)
  11. {
  12. return stencilFail == StencilOperation::kKeep && stencilPassDepthFail == StencilOperation::kKeep
  13. && stencilPassDepthPass == StencilOperation::kKeep && compare == CompareOperation::kAlways;
  14. }
  15. inline Bool blendingDisabled(BlendFactor srcFactorRgb, BlendFactor dstFactorRgb, BlendFactor srcFactorA, BlendFactor dstFactorA, BlendOperation opRgb,
  16. BlendOperation opA)
  17. {
  18. Bool dontWantBlend = srcFactorRgb == BlendFactor::kOne && dstFactorRgb == BlendFactor::kZero && srcFactorA == BlendFactor::kOne
  19. && dstFactorA == BlendFactor::kZero && (opRgb == BlendOperation::kAdd || opRgb == BlendOperation::kSubtract)
  20. && (opA == BlendOperation::kAdd || opA == BlendOperation::kSubtract);
  21. return dontWantBlend;
  22. }
  23. /// Using an AnKi typename get the ShaderVariableDataType. Used for debugging.
  24. template<typename T>
  25. ShaderVariableDataType getShaderVariableTypeFromTypename();
  26. #define ANKI_SVDT_MACRO(type, baseType, rowCount, columnCount, isIntagralType) \
  27. template<> \
  28. inline ShaderVariableDataType getShaderVariableTypeFromTypename<type>() \
  29. { \
  30. return ShaderVariableDataType::k##type; \
  31. }
  32. #include <AnKi/Gr/ShaderVariableDataType.def.h>
  33. #undef ANKI_SVDT_MACRO
  34. /// Populate the memory of a variable that is inside a shader block.
  35. void writeShaderBlockMemory(ShaderVariableDataType type, const ShaderVariableBlockInfo& varBlkInfo, const void* elements, U32 elementsCount,
  36. void* buffBegin, const void* buffEnd);
  37. } // end namespace anki