/// <summary> /// Constructs a new instance of the texture bindings manager. /// </summary> /// <param name="context">The GPU context that the texture bindings manager belongs to</param> /// <param name="channel">The GPU channel that the texture bindings manager belongs to</param> /// <param name="texturePoolCache">Texture pools cache used to get texture pools from</param> /// <param name="samplerPoolCache">Sampler pools cache used to get sampler pools from</param> /// <param name="scales">Array where the scales for the currently bound textures are stored</param> /// <param name="isCompute">True if the bindings manager is used for the compute engine</param> public TextureBindingsManager( GpuContext context, GpuChannel channel, TexturePoolCache texturePoolCache, SamplerPoolCache samplerPoolCache, float[] scales, bool isCompute) { _context = context; _channel = channel; _texturePoolCache = texturePoolCache; _samplerPoolCache = samplerPoolCache; _scales = scales; _isCompute = isCompute; int stages = isCompute ? 1 : Constants.ShaderStages; _textureBindings = new TextureBindingInfo[stages][]; _imageBindings = new TextureBindingInfo[stages][]; _textureState = new TextureState[InitialTextureStateSize]; _imageState = new TextureState[InitialImageStateSize]; _textureBindingsCount = new int[stages]; _imageBindingsCount = new int[stages]; for (int stage = 0; stage < stages; stage++) { _textureBindings[stage] = new TextureBindingInfo[InitialTextureStateSize]; _imageBindings[stage] = new TextureBindingInfo[InitialImageStateSize]; } }
/// <summary> /// Creates a new instance of the texture manager. /// </summary> /// <param name="context">GPU context that the texture manager belongs to</param> /// <param name="channel">GPU channel that the texture manager belongs to</param> public TextureManager(GpuContext context, GpuChannel channel) { _context = context; _channel = channel; TexturePoolCache texturePoolCache = new TexturePoolCache(context); SamplerPoolCache samplerPoolCache = new SamplerPoolCache(context); float[] scales = new float[64]; new Span <float>(scales).Fill(1f); _cpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, samplerPoolCache, scales, isCompute: true); _gpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, samplerPoolCache, scales, isCompute: false); _texturePoolCache = texturePoolCache; _samplerPoolCache = samplerPoolCache; _rtColors = new Texture[Constants.TotalRenderTargets]; _rtHostColors = new ITexture[Constants.TotalRenderTargets]; }