/// <summary> /// Create the array of brick metadata for use in the compute shader based on the bricks in the currentVolume. /// </summary> /// <returns></returns> private MetaBrick[] initMetaBrickBuffer() { MetaBrick[] metaBricks = new MetaBrick[currentVolume.Bricks.Length];//Make an array of MetaBricks. for (int i = 0; i < metaBricks.Length; i++)//This controls what Z level is loaded INTO THE BUFFERS. { // Create the MetaBrick metaBricks[i] = currentVolume.Bricks[i].getMetaBrick(); metaBricks[i].currentZLevel = Math.Min(metaBricks[i].maxZLevel, 8); // This is done in order to pack GrayRot into the buffers at a maximum of level 8. z=9 overflows the buffer. // Much has been tried to load the full GrayRot data (~25 GB), but we run out of buffer space. A buffer can be a max of 2 GB under normal operation. // We are limited to five buffers of data. Thus we can load a MAXIMUM of 10 GB of data. // As of 12/19/2018 I do not know of a way around this. // See my thoughts in the white paper writeup as to why these constraints are difficult to overcome. metaBricks[i].id = i; metaBricks[i].lastBitMask = currentVolume.Bricks[i].calculateLastBitMask(); // Set some parameters in the brick currentVolume.Bricks[i].CurrentZLevel = metaBricks[i].currentZLevel; } return(metaBricks); }
/* * A method used by the VolumeController object in the GeneralControlsHandler to update the MetaBrickBuffer with a new Z-level setting. * Note that this does NOT update the actual raw data buffer. */ public void updateMetaBrickBuffer(int newZlevel) { MetaBrick[] mbBuff = new MetaBrick[this.CurrentVolume.Bricks.Length]; metaBrickBuffer.GetData(mbBuff); for (int i = 0; i < mbBuff.Length; i++) { // Update the actual Brick objects in the volume. currentVolume.Bricks[i].CurrentZLevel = newZlevel; //Update the associated MetaBrick. We run the update through the actual brick first to enforce clamping to maximal level. //If you directly assign the MetaBrick the newZlevel, then you can overrun the available z levels when you have bricks of different sizes. //By passing the newZlevel through the actual brick first, we clamp the z level of the metaBrick to at most the maxZLevel. mbBuff[i].currentZLevel = currentVolume.Bricks[i].CurrentZLevel;// } metaBrickBuffer.SetData(mbBuff); }
/// <summary> /// Determine the amount of data voxels to be read in for the given brick. /// </summary> /// <param name="br"></param> /// <returns></returns> private int getMetaBrickDataSize(MetaBrick br) { int numData = 1 << br.currentZLevel; //This yields 2^br.currentZLevel return(numData * numData * numData); }