Beispiel #1
0
        public Result CreateImage(MgImageCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgImage pImage)
        {
            if (pCreateInfo == null)
            {
                throw new ArgumentNullException("pCreateInfo");
            }

            // ARB_texture_storage
            int[] textureId = new int[1];

            int width       = (int)pCreateInfo.Extent.Width;
            int height      = (int)pCreateInfo.Extent.Height;
            int depth       = (int)pCreateInfo.Extent.Depth;
            int levels      = (int)pCreateInfo.MipLevels;
            int arrayLayers = (int)pCreateInfo.ArrayLayers;
            //var internalFormat = GetInternalFormat(pCreateInfo.Format);

            var imageType = pCreateInfo.ImageType;

            switch (pCreateInfo.ImageType)
            {
            case MgImageType.TYPE_1D:
//				GL.CreateTextures (TextureTarget.Texture1D, 1, textureId);
//				GL.Ext.TextureStorage1D (textureId [0], (ExtDirectStateAccess)All.Texture1D, levels, internalFormat, width);
                textureId[0] = mEntrypoint.Image.CreateTextureStorage1D(levels, pCreateInfo.Format, width);
                break;

            case MgImageType.TYPE_2D:
//				GL.CreateTextures (TextureTarget.Texture2D, 1, textureId);
//				GL.Ext.TextureStorage2D (textureId[0], (ExtDirectStateAccess)All.Texture2D, levels, internalFormat, width, height);
                textureId[0] = mEntrypoint.Image.CreateTextureStorage2D(levels, pCreateInfo.Format, width, height);
                break;

            case MgImageType.TYPE_3D:
//				GL.CreateTextures (TextureTarget.Texture3D, 1, textureId);
//				GL.Ext.TextureStorage3D (textureId [0], (ExtDirectStateAccess)All.Texture3D, levels, internalFormat, width, height, depth);
                textureId [0] = mEntrypoint.Image.CreateTextureStorage3D(levels, pCreateInfo.Format, width, height, depth);
                break;

            default:
                throw new NotSupportedException();
            }

            pImage = new GLImage(mEntrypoint.Image, textureId[0], imageType, pCreateInfo.Format, width, height, depth, levels, arrayLayers);
            return(Result.SUCCESS);
        }
Beispiel #2
0
        public Result CreateImage(MgImageCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgImage pImage)
        {
            Debug.Assert(pCreateInfo != null);

            var depth       = (nuint)pCreateInfo.Extent.Depth;
            var height      = (nuint)pCreateInfo.Extent.Height;
            var width       = (nuint)pCreateInfo.Extent.Width;
            var arrayLayers = (nuint)pCreateInfo.ArrayLayers;
            var mipLevels   = (nuint)pCreateInfo.MipLevels;

            //TODO : Figure this out
            var storageMode     = MTLStorageMode.Shared;
            var resourceOptions = MTLResourceOptions.CpuCacheModeDefault;
            var cpuCacheMode    = MTLCpuCacheMode.DefaultCache;

            var descriptor = new MTLTextureDescriptor
            {
                ArrayLength      = arrayLayers,
                PixelFormat      = AmtFormatExtensions.GetPixelFormat(pCreateInfo.Format),
                SampleCount      = AmtSampleCountFlagBitExtensions.TranslateSampleCount(pCreateInfo.Samples),
                TextureType      = TranslateTextureType(pCreateInfo.ImageType),
                StorageMode      = storageMode,
                Width            = width,
                Height           = height,
                Depth            = depth,
                MipmapLevelCount = mipLevels,
                Usage            = TranslateUsage(pCreateInfo.Usage),
                ResourceOptions  = resourceOptions,
                CpuCacheMode     = cpuCacheMode,
            };

            var texture = mDevice.CreateTexture(descriptor);

            pImage = new AmtImage(texture);
            return(Result.SUCCESS);
        }
Beispiel #3
0
 public Result CreateImage(MgImageCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgImage pImage)
 {
     throw new NotImplementedException();
 }