//public bool HasAlpha => !(Min.Alpha == 1.0f && Max.Alpha == 1.0f); internal float GetStats(ITexture texture, int layer, int mipmap, StatisticsShader statShader, ReduceShader redShader, bool normalize) { // obtain a buffer that is big enough int numElements = texture.Size.GetMip(mipmap).Product; if (layer == -1) { numElements *= texture.NumLayers; } if (buffer == null || buffer.ElementCount < numElements) { buffer?.Dispose(); buffer = new GpuBuffer(4, numElements); } // copy all values into buffer statShader.CopyToBuffer(texture, buffer, layer, mipmap); // execute reduce redShader.Run(buffer, numElements); shared.Download.CopyFrom(buffer); var res = shared.Download.GetData <float>(); if (normalize) { res /= numElements; } return(res); }
/// <summary> /// allocates a buffer that is big enough to hold numElement floats /// </summary> /// <param name="numElements"></param> /// <returns></returns> internal GpuBuffer GetBuffer(int numElements) { if (buffer == null || buffer.ElementCount < numElements) { buffer?.Dispose(); buffer = new GpuBuffer(4, numElements); } return(buffer); }
public override void Dispose() { coordDstBuffer.Dispose(); coordShader.Dispose(); base.Dispose(); }
public void Dispose() { shader2D?.Dispose(); shader3D?.Dispose(); dstBuffer?.Dispose(); }
protected override void DisposeManaged() { vertexBuffer.Dispose(); indexBuffer.Dispose(); vao.Dispose(); }