Functions.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 stencilTestEnabled(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 depthTestEnabled(CompareOperation depthCompare, Bool depthWrite)
  16. {
  17. return depthCompare != CompareOperation::kAlways || depthWrite;
  18. }
  19. inline Bool blendingEnabled(BlendFactor srcFactorRgb, BlendFactor dstFactorRgb, BlendFactor srcFactorA, BlendFactor dstFactorA, BlendOperation opRgb,
  20. BlendOperation opA)
  21. {
  22. const Bool dontWantBlend = srcFactorRgb == BlendFactor::kOne && dstFactorRgb == BlendFactor::kZero && srcFactorA == BlendFactor::kOne
  23. && dstFactorA == BlendFactor::kZero && (opRgb == BlendOperation::kAdd || opRgb == BlendOperation::kSubtract)
  24. && (opA == BlendOperation::kAdd || opA == BlendOperation::kSubtract);
  25. return !dontWantBlend;
  26. }
  27. /// Using an AnKi typename get the ShaderVariableDataType. Used for debugging.
  28. template<typename T>
  29. ShaderVariableDataType getShaderVariableTypeFromTypename();
  30. #define ANKI_SVDT_MACRO(type, baseType, rowCount, columnCount, isIntagralType) \
  31. template<> \
  32. inline ShaderVariableDataType getShaderVariableTypeFromTypename<type>() \
  33. { \
  34. return ShaderVariableDataType::k##type; \
  35. }
  36. #include <AnKi/Gr/ShaderVariableDataType.def.h>
  37. /// Populate the memory of a variable that is inside a shader block.
  38. void writeShaderBlockMemory(ShaderVariableDataType type, const ShaderVariableBlockInfo& varBlkInfo, const void* elements, U32 elementsCount,
  39. void* buffBegin, const void* buffEnd);
  40. } // end namespace anki