GLState.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __GLSTATE_H__
  21. #define __GLSTATE_H__
  22. // one/zero is flipped on src/dest so a gl state of 0 is SRC_ONE,DST_ZERO
  23. static const uint64 GLS_SRCBLEND_ONE = 0 << 0;
  24. static const uint64 GLS_SRCBLEND_ZERO = 1 << 0;
  25. static const uint64 GLS_SRCBLEND_DST_COLOR = 2 << 0;
  26. static const uint64 GLS_SRCBLEND_ONE_MINUS_DST_COLOR = 3 << 0;
  27. static const uint64 GLS_SRCBLEND_SRC_ALPHA = 4 << 0;
  28. static const uint64 GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA = 5 << 0;
  29. static const uint64 GLS_SRCBLEND_DST_ALPHA = 6 << 0;
  30. static const uint64 GLS_SRCBLEND_ONE_MINUS_DST_ALPHA = 7 << 0;
  31. static const uint64 GLS_SRCBLEND_BITS = 7 << 0;
  32. static const uint64 GLS_DSTBLEND_ZERO = 0 << 3;
  33. static const uint64 GLS_DSTBLEND_ONE = 1 << 3;
  34. static const uint64 GLS_DSTBLEND_SRC_COLOR = 2 << 3;
  35. static const uint64 GLS_DSTBLEND_ONE_MINUS_SRC_COLOR = 3 << 3;
  36. static const uint64 GLS_DSTBLEND_SRC_ALPHA = 4 << 3;
  37. static const uint64 GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA = 5 << 3;
  38. static const uint64 GLS_DSTBLEND_DST_ALPHA = 6 << 3;
  39. static const uint64 GLS_DSTBLEND_ONE_MINUS_DST_ALPHA = 7 << 3;
  40. static const uint64 GLS_DSTBLEND_BITS = 7 << 3;
  41. //------------------------
  42. // these masks are the inverse, meaning when set the glColorMask value will be 0,
  43. // preventing that channel from being written
  44. //------------------------
  45. static const uint64 GLS_DEPTHMASK = 1 << 6;
  46. static const uint64 GLS_REDMASK = 1 << 7;
  47. static const uint64 GLS_GREENMASK = 1 << 8;
  48. static const uint64 GLS_BLUEMASK = 1 << 9;
  49. static const uint64 GLS_ALPHAMASK = 1 << 10;
  50. static const uint64 GLS_COLORMASK = (GLS_REDMASK|GLS_GREENMASK|GLS_BLUEMASK);
  51. static const uint64 GLS_POLYMODE_LINE = 1 << 11;
  52. static const uint64 GLS_POLYGON_OFFSET = 1 << 12;
  53. static const uint64 GLS_DEPTHFUNC_LESS = 0 << 13;
  54. static const uint64 GLS_DEPTHFUNC_ALWAYS = 1 << 13;
  55. static const uint64 GLS_DEPTHFUNC_GREATER = 2 << 13;
  56. static const uint64 GLS_DEPTHFUNC_EQUAL = 3 << 13;
  57. static const uint64 GLS_DEPTHFUNC_BITS = 3 << 13;
  58. static const uint64 GLS_BLENDOP_ADD = 0 << 18;
  59. static const uint64 GLS_BLENDOP_SUB = 1 << 18;
  60. static const uint64 GLS_BLENDOP_MIN = 2 << 18;
  61. static const uint64 GLS_BLENDOP_MAX = 3 << 18;
  62. static const uint64 GLS_BLENDOP_BITS = 3 << 18;
  63. // stencil bits
  64. static const uint64 GLS_STENCIL_FUNC_REF_SHIFT = 20;
  65. static const uint64 GLS_STENCIL_FUNC_REF_BITS = 0xFFll << GLS_STENCIL_FUNC_REF_SHIFT;
  66. static const uint64 GLS_STENCIL_FUNC_MASK_SHIFT = 28;
  67. static const uint64 GLS_STENCIL_FUNC_MASK_BITS = 0xFFll << GLS_STENCIL_FUNC_MASK_SHIFT;
  68. #define GLS_STENCIL_MAKE_REF( x ) ( ( (uint64)(x) << GLS_STENCIL_FUNC_REF_SHIFT ) & GLS_STENCIL_FUNC_REF_BITS )
  69. #define GLS_STENCIL_MAKE_MASK( x ) ( ( (uint64)(x) << GLS_STENCIL_FUNC_MASK_SHIFT ) & GLS_STENCIL_FUNC_MASK_BITS )
  70. static const uint64 GLS_STENCIL_FUNC_ALWAYS = 0ull << 36;
  71. static const uint64 GLS_STENCIL_FUNC_LESS = 1ull << 36;
  72. static const uint64 GLS_STENCIL_FUNC_LEQUAL = 2ull << 36;
  73. static const uint64 GLS_STENCIL_FUNC_GREATER = 3ull << 36;
  74. static const uint64 GLS_STENCIL_FUNC_GEQUAL = 4ull << 36;
  75. static const uint64 GLS_STENCIL_FUNC_EQUAL = 5ull << 36;
  76. static const uint64 GLS_STENCIL_FUNC_NOTEQUAL = 6ull << 36;
  77. static const uint64 GLS_STENCIL_FUNC_NEVER = 7ull << 36;
  78. static const uint64 GLS_STENCIL_FUNC_BITS = 7ull << 36;
  79. static const uint64 GLS_STENCIL_OP_FAIL_KEEP = 0ull << 39;
  80. static const uint64 GLS_STENCIL_OP_FAIL_ZERO = 1ull << 39;
  81. static const uint64 GLS_STENCIL_OP_FAIL_REPLACE = 2ull << 39;
  82. static const uint64 GLS_STENCIL_OP_FAIL_INCR = 3ull << 39;
  83. static const uint64 GLS_STENCIL_OP_FAIL_DECR = 4ull << 39;
  84. static const uint64 GLS_STENCIL_OP_FAIL_INVERT = 5ull << 39;
  85. static const uint64 GLS_STENCIL_OP_FAIL_INCR_WRAP = 6ull << 39;
  86. static const uint64 GLS_STENCIL_OP_FAIL_DECR_WRAP = 7ull << 39;
  87. static const uint64 GLS_STENCIL_OP_FAIL_BITS = 7ull << 39;
  88. static const uint64 GLS_STENCIL_OP_ZFAIL_KEEP = 0ull << 42;
  89. static const uint64 GLS_STENCIL_OP_ZFAIL_ZERO = 1ull << 42;
  90. static const uint64 GLS_STENCIL_OP_ZFAIL_REPLACE = 2ull << 42;
  91. static const uint64 GLS_STENCIL_OP_ZFAIL_INCR = 3ull << 42;
  92. static const uint64 GLS_STENCIL_OP_ZFAIL_DECR = 4ull << 42;
  93. static const uint64 GLS_STENCIL_OP_ZFAIL_INVERT = 5ull << 42;
  94. static const uint64 GLS_STENCIL_OP_ZFAIL_INCR_WRAP = 6ull << 42;
  95. static const uint64 GLS_STENCIL_OP_ZFAIL_DECR_WRAP = 7ull << 42;
  96. static const uint64 GLS_STENCIL_OP_ZFAIL_BITS = 7ull << 42;
  97. static const uint64 GLS_STENCIL_OP_PASS_KEEP = 0ull << 45;
  98. static const uint64 GLS_STENCIL_OP_PASS_ZERO = 1ull << 45;
  99. static const uint64 GLS_STENCIL_OP_PASS_REPLACE = 2ull << 45;
  100. static const uint64 GLS_STENCIL_OP_PASS_INCR = 3ull << 45;
  101. static const uint64 GLS_STENCIL_OP_PASS_DECR = 4ull << 45;
  102. static const uint64 GLS_STENCIL_OP_PASS_INVERT = 5ull << 45;
  103. static const uint64 GLS_STENCIL_OP_PASS_INCR_WRAP = 6ull << 45;
  104. static const uint64 GLS_STENCIL_OP_PASS_DECR_WRAP = 7ull << 45;
  105. static const uint64 GLS_STENCIL_OP_PASS_BITS = 7ull << 45;
  106. static const uint64 GLS_ALPHATEST_FUNC_REF_SHIFT = 48;
  107. static const uint64 GLS_ALPHATEST_FUNC_REF_BITS = 0xFFll << GLS_ALPHATEST_FUNC_REF_SHIFT;
  108. #define GLS_ALPHATEST_MAKE_REF( x ) ( ( (uint64)(x) << GLS_ALPHATEST_FUNC_REF_SHIFT ) & GLS_ALPHATEST_FUNC_REF_BITS )
  109. static const uint64 GLS_ALPHATEST_FUNC_ALWAYS = 0ull << 56;
  110. static const uint64 GLS_ALPHATEST_FUNC_LESS = 1ull << 56;
  111. static const uint64 GLS_ALPHATEST_FUNC_GREATER = 2ull << 56;
  112. static const uint64 GLS_ALPHATEST_FUNC_EQUAL = 3ull << 56;
  113. static const uint64 GLS_ALPHATEST_FUNC_BITS = 3ull << 56;
  114. static const uint64 GLS_STENCIL_OP_BITS = GLS_STENCIL_OP_FAIL_BITS | GLS_STENCIL_OP_ZFAIL_BITS | GLS_STENCIL_OP_PASS_BITS;
  115. static const uint64 GLS_OVERRIDE = 1ull << 63; // override the render prog state
  116. static const uint64 GLS_DEFAULT = 0;
  117. #define STENCIL_SHADOW_TEST_VALUE 128
  118. #define STENCIL_SHADOW_MASK_VALUE 255
  119. #endif /* !__GLSTATE_H__ */