webgpuStencilStateComposer.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { StencilStateComposer } from "../../States/stencilStateComposer.js";
  2. /**
  3. * @internal
  4. **/
  5. export class WebGPUStencilStateComposer extends StencilStateComposer {
  6. constructor(cache) {
  7. super(false);
  8. this._cache = cache;
  9. this.reset();
  10. }
  11. get func() {
  12. return this._func;
  13. }
  14. set func(value) {
  15. if (this._func === value) {
  16. return;
  17. }
  18. this._func = value;
  19. this._cache.setStencilCompare(value);
  20. }
  21. get funcMask() {
  22. return this._funcMask;
  23. }
  24. set funcMask(value) {
  25. if (this._funcMask === value) {
  26. return;
  27. }
  28. this._funcMask = value;
  29. this._cache.setStencilReadMask(value);
  30. }
  31. get opStencilFail() {
  32. return this._opStencilFail;
  33. }
  34. set opStencilFail(value) {
  35. if (this._opStencilFail === value) {
  36. return;
  37. }
  38. this._opStencilFail = value;
  39. this._cache.setStencilFailOp(value);
  40. }
  41. get opDepthFail() {
  42. return this._opDepthFail;
  43. }
  44. set opDepthFail(value) {
  45. if (this._opDepthFail === value) {
  46. return;
  47. }
  48. this._opDepthFail = value;
  49. this._cache.setStencilDepthFailOp(value);
  50. }
  51. get opStencilDepthPass() {
  52. return this._opStencilDepthPass;
  53. }
  54. set opStencilDepthPass(value) {
  55. if (this._opStencilDepthPass === value) {
  56. return;
  57. }
  58. this._opStencilDepthPass = value;
  59. this._cache.setStencilPassOp(value);
  60. }
  61. get mask() {
  62. return this._mask;
  63. }
  64. set mask(value) {
  65. if (this._mask === value) {
  66. return;
  67. }
  68. this._mask = value;
  69. this._cache.setStencilWriteMask(value);
  70. }
  71. get enabled() {
  72. return this._enabled;
  73. }
  74. set enabled(value) {
  75. if (this._enabled === value) {
  76. return;
  77. }
  78. this._enabled = value;
  79. this._cache.setStencilEnabled(value);
  80. }
  81. reset() {
  82. super.reset();
  83. this._cache.resetStencilState();
  84. }
  85. apply() {
  86. const stencilMaterialEnabled = this.stencilMaterial?.enabled;
  87. this.enabled = stencilMaterialEnabled ? this.stencilMaterial.enabled : this.stencilGlobal.enabled;
  88. if (!this.enabled) {
  89. return;
  90. }
  91. this.func = stencilMaterialEnabled ? this.stencilMaterial.func : this.stencilGlobal.func;
  92. this.funcRef = stencilMaterialEnabled ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef;
  93. this.funcMask = stencilMaterialEnabled ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask;
  94. this.opStencilFail = stencilMaterialEnabled ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail;
  95. this.opDepthFail = stencilMaterialEnabled ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail;
  96. this.opStencilDepthPass = stencilMaterialEnabled ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass;
  97. this.mask = stencilMaterialEnabled ? this.stencilMaterial.mask : this.stencilGlobal.mask;
  98. }
  99. }
  100. //# sourceMappingURL=webgpuStencilStateComposer.js.map