shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$renderTarget$GlobalUniformSystem = function(global, require, module, exports) {
  global = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions");
  var Matrix = require("module$node_modules$pixi_DOT_js$lib$maths$matrix$Matrix"), Point = require("module$node_modules$pixi_DOT_js$lib$maths$point$Point"), colorToUniform = require("module$node_modules$pixi_DOT_js$lib$scene$graphics$gpu$colorToUniform"), BindGroup = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$shader$BindGroup"), types = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$types"), UniformGroup = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$shader$UniformGroup");
  "use strict";
  class GlobalUniformSystem {
    constructor(renderer) {
      this._stackIndex = 0;
      this._globalUniformDataStack = [];
      this._uniformsPool = [];
      this._activeUniforms = [];
      this._bindGroupPool = [];
      this._activeBindGroups = [];
      this._renderer = renderer;
    }
    reset() {
      this._stackIndex = 0;
      for (var i = 0; i < this._activeUniforms.length; i++) {
        this._uniformsPool.push(this._activeUniforms[i]);
      }
      for (i = 0; i < this._activeBindGroups.length; i++) {
        this._bindGroupPool.push(this._activeBindGroups[i]);
      }
      this._activeUniforms.length = 0;
      this._activeBindGroups.length = 0;
    }
    start(options) {
      this.reset();
      this.push(options);
    }
    bind({size, projectionMatrix, worldTransformMatrix, worldColor, offset}) {
      const renderTarget = this._renderer.renderTarget.renderTarget, currentGlobalUniformData = this._stackIndex ? this._globalUniformDataStack[this._stackIndex - 1] : {projectionData:renderTarget, worldTransformMatrix:new Matrix.Matrix(), worldColor:4294967295, offset:new Point.Point()};
      size = {projectionMatrix:projectionMatrix || this._renderer.renderTarget.projectionMatrix, resolution:size || renderTarget.size, worldTransformMatrix:worldTransformMatrix || currentGlobalUniformData.worldTransformMatrix, worldColor:worldColor || currentGlobalUniformData.worldColor, offset:offset || currentGlobalUniformData.offset, bindGroup:null};
      projectionMatrix = this._uniformsPool.pop() || this._createUniforms();
      this._activeUniforms.push(projectionMatrix);
      worldTransformMatrix = projectionMatrix.uniforms;
      worldTransformMatrix.uProjectionMatrix = size.projectionMatrix;
      worldTransformMatrix.uResolution = size.resolution;
      worldTransformMatrix.uWorldTransformMatrix.copyFrom(size.worldTransformMatrix);
      worldTransformMatrix.uWorldTransformMatrix.tx -= size.offset.x;
      worldTransformMatrix.uWorldTransformMatrix.ty -= size.offset.y;
      colorToUniform.color32BitToUniform(size.worldColor, worldTransformMatrix.uWorldColorAlpha, 0);
      projectionMatrix.update();
      this._renderer.renderPipes.uniformBatch ? worldTransformMatrix = this._renderer.renderPipes.uniformBatch.getUniformBindGroup(projectionMatrix, !1) : (worldTransformMatrix = this._bindGroupPool.pop() || new BindGroup.BindGroup(), this._activeBindGroups.push(worldTransformMatrix), worldTransformMatrix.setResource(projectionMatrix, 0));
      size.bindGroup = worldTransformMatrix;
      this._currentGlobalUniformData = size;
    }
    push(options) {
      this.bind(options);
      this._globalUniformDataStack[this._stackIndex++] = this._currentGlobalUniformData;
    }
    pop() {
      this._currentGlobalUniformData = this._globalUniformDataStack[--this._stackIndex - 1];
      this._renderer.type === types.RendererType.WEBGL && this._currentGlobalUniformData.bindGroup.resources[0].update();
    }
    get bindGroup() {
      return this._currentGlobalUniformData.bindGroup;
    }
    get globalUniformData() {
      return this._currentGlobalUniformData;
    }
    get uniformGroup() {
      return this._currentGlobalUniformData.bindGroup.resources[0];
    }
    _createUniforms() {
      return new UniformGroup.UniformGroup({uProjectionMatrix:{value:new Matrix.Matrix(), type:"mat3x3\x3cf32\x3e"}, uWorldTransformMatrix:{value:new Matrix.Matrix(), type:"mat3x3\x3cf32\x3e"}, uWorldColorAlpha:{value:new Float32Array(4), type:"vec4\x3cf32\x3e"}, uResolution:{value:[0, 0], type:"vec2\x3cf32\x3e"}}, {isStatic:!0});
    }
    destroy() {
      this._renderer = null;
      this._globalUniformDataStack.length = 0;
      this._uniformsPool.length = 0;
      this._activeUniforms.length = 0;
      this._bindGroupPool.length = 0;
      this._activeBindGroups.length = 0;
      this._currentGlobalUniformData = null;
    }
  }
  GlobalUniformSystem.extension = {type:[global.ExtensionType.WebGLSystem, global.ExtensionType.WebGPUSystem, global.ExtensionType.CanvasSystem], name:"globalUniforms"};
  exports.GlobalUniformSystem = GlobalUniformSystem;
};

//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$renderTarget$GlobalUniformSystem.js.map
