updateSampler method

dynamic updateSampler(
  1. dynamic texture
)

Implementation

updateSampler(texture) {
  var array = [];

  array.add(texture.wrapS);
  array.add(texture.wrapT);
  array.add(texture.wrapR);
  array.add(texture.magFilter);
  array.add(texture.minFilter);
  array.add(texture.anisotropy);

  var key = array.join();
  var samplerGPU = this.samplerCache.get(key);

  if (samplerGPU == undefined) {
    samplerGPU = this.device.createSampler(GPUSamplerDescriptor(
        addressModeU: this._convertAddressMode(texture.wrapS),
        addressModeV: this._convertAddressMode(texture.wrapT),
        addressModeW: this._convertAddressMode(texture.wrapR),
        magFilter: this._convertFilterMode(texture.magFilter),
        minFilter: this._convertFilterMode(texture.minFilter),
        mipmapFilter: this._convertFilterMode(texture.minFilter),
        maxAnisotropy: texture.anisotropy));

    this.samplerCache.set(key, samplerGPU);
  }

  var textureProperties = this.properties.get(texture);
  textureProperties.samplerGPU = samplerGPU;
}