Example #1
0
//		public void DestroyImage (MgImage image, IMgAllocationCallbacks allocator)
//		{
//			mImages [image.Key].Destroy ();
//		}

        public void GetImageSubresourceLayout(IMgImage image, MgImageSubresource pSubresource, out MgSubresourceLayout pLayout)
        {
            var internalImage = (IGLImage)image;

            if (internalImage != null &&
                pSubresource.ArrayLayer < internalImage.ArrayLayers.Length &&
                pSubresource.MipLevel < internalImage.ArrayLayers[pSubresource.ArrayLayer].Levels.Length)
            {
                pLayout = internalImage.ArrayLayers [pSubresource.ArrayLayer].Levels [pSubresource.MipLevel].SubresourceLayout;
            }
            else
            {
                pLayout = new MgSubresourceLayout {
                };
            }
        }
Example #2
0
 public void GetImageSubresourceLayout(IMgImage image, MgImageSubresource pSubresource, out MgSubresourceLayout pLayout)
 {
     throw new NotImplementedException();
 }
Example #3
0
        private void GenerateMipmapLevels()
        {
            ulong imageSize = 0;
            ulong offset    = 0;

            uint width  = (uint)mWidth;
            uint height = (uint)mHeight;
            uint depth  = (uint)mDepth;

            //
            uint pixelSize = GetSize(mFormat);

            mArraySubresources = new GLImageArraySubresource[mLayers];

            for (uint index = 0; index < mLayers; ++index)
            {
                var arrayItem = new GLImageArraySubresource(index, new GLImageLevelSubresource[mLevels]);

                for (uint level = 0; level < mLevels; ++level)
                {
                    switch (mFormat)
                    {
                    // FIXME :
                    //				//case SurfaceFormat.RgbPvrtc2Bpp:
                    //				case SurfaceFormat.RgbaPvrtc2Bpp:
                    //					imageSize = (Math.Max(this.width, 16) * Math.Max(this.height, 8) * 2 + 7) / 8;
                    //					break;
                    //				case SurfaceFormat.RgbPvrtc4Bpp:
                    //				case SurfaceFormat.RgbaPvrtc4Bpp:
                    //					imageSize = (Math.Max(this.width, 8) * Math.Max(this.height, 8) * 4 + 7) / 8;
                    //					break;
                    case MgFormat.BC1_RGB_UNORM_BLOCK:
                    //case SurfaceFormat.Dxt1:
                    case MgFormat.BC1_RGBA_UNORM_BLOCK:
                    //case SurfaceFormat.Dxt1a:
                    case MgFormat.BC1_RGB_SRGB_BLOCK:
                    //case SurfaceFormat.Dxt1SRgb:
                    case MgFormat.BC2_UNORM_BLOCK:
                    //case SurfaceFormat.Dxt3:
                    case MgFormat.BC2_SRGB_BLOCK:
                    //case SurfaceFormat.Dxt3SRgb:
                    case MgFormat.BC3_UNORM_BLOCK:
                    //case SurfaceFormat.Dxt5:
                    case MgFormat.BC3_SRGB_BLOCK:
                        //case SurfaceFormat.Dxt5SRgb:
                        //case SurfaceFormat.RgbEtc1:
                        //case SurfaceFormat.RgbaAtcExplicitAlpha:
                        //case SurfaceFormat.RgbaAtcInterpolatedAlpha:

                        // TODO : include depth SOMEHOW
                        imageSize = ((width + 3) / 4) * ((height + 3) / 4) * pixelSize;
                        break;

                    default:
                        imageSize = pixelSize * width * height * depth;
                        break;
                        //return Result.ERROR_FEATURE_NOT_PRESENT;
                    }

                    var current = new MgSubresourceLayout {
                        Offset     = offset,
                        Size       = imageSize,
                        ArrayPitch = RoundPixelUp(imageSize),
                        RowPitch   = (mImageType == MgImageType.TYPE_1D) ? 0U : RoundPixelUp(width),
                        DepthPitch = (mImageType == MgImageType.TYPE_1D || mImageType == MgImageType.TYPE_2D) ? 0U : RoundPixelUp(depth),
                    };

                    var mipLevelData = new GLImageLevelSubresource();
                    mipLevelData.Width             = (int)width;
                    mipLevelData.Height            = (int)height;
                    mipLevelData.Depth             = (int)depth;
                    mipLevelData.SubresourceLayout = current;

                    arrayItem.Levels [level] = mipLevelData;

                    // for next array item
                    offset += current.ArrayPitch;

                    if (width > 1)
                    {
                        width /= 2;
                    }

                    if (height > 1)
                    {
                        height /= 2;
                    }

                    if (depth > 1)
                    {
                        depth /= 2;
                    }
                }
                mArraySubresources [index] = arrayItem;
            }
        }