Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ============
  2. //
  3. // intelglmallocworkaround.h
  4. // class responsible for setting up a malloc override that zeroes allocated
  5. // memory of less than 96 bytes. this is to work around a bug
  6. // in the Intel GLSL compiler on Mac OS X 10.8 due to uninitialized memory.
  7. //
  8. // 96 was chosen due to this quote from Apple:
  9. // "I verified that the size of the structure is exactly 64 bytes on 10.8.3, 10.8.4 and will be on 10.8.5."
  10. //
  11. // certain GLSL shaders would (intermittently) cause a crash the first time they
  12. // were drawn, and the bug has supposedly been fixed in 10.9, but is unlikely to
  13. // ever make it to 10.8.
  14. //
  15. //===============================================================================
  16. #ifndef INTELGLMALLOCWORKAROUND_H
  17. #define INTELGLMALLOCWORKAROUND_H
  18. #include <stdlib.h>
  19. class IntelGLMallocWorkaround
  20. {
  21. public:
  22. static IntelGLMallocWorkaround *Get();
  23. bool Enable();
  24. protected:
  25. IntelGLMallocWorkaround() :m_pfnMallocReentry(NULL) {}
  26. ~IntelGLMallocWorkaround() {}
  27. static IntelGLMallocWorkaround *s_pWorkaround;
  28. static void* ZeroingAlloc(size_t);
  29. typedef void* (*pfnMalloc_t)(size_t);
  30. pfnMalloc_t m_pfnMallocReentry;
  31. };
  32. #endif // INTELGLMALLOCWORKAROUND_H