示例#1
0
        private void PlatformConstruct(
            GraphicsDevice graphicsDevice,
            ResourceUploadBatch uploadBatch,
            PixelFormat pixelFormat,
            int width,
            int height,
            TextureMipMapData[] mipMapData)
        {
            var textureDescriptor = MTLTextureDescriptor.CreateTexture2DDescriptor(
                pixelFormat.ToMTLPixelFormat(),
                (nuint)width,
                (nuint)height,
                true); // Ignored, because we'll set the mip level count explicitly below.

            textureDescriptor.Usage = MTLTextureUsage.ShaderRead;

            textureDescriptor.MipmapLevelCount = (nuint)mipMapData.Length;

            _originalPixelFormat = pixelFormat;

            DeviceTexture = AddDisposable(graphicsDevice.Device.CreateTexture(textureDescriptor));

            for (var i = 0; i < mipMapData.Length; i++)
            {
                SetData(
                    i,
                    mipMapData[i].Data,
                    mipMapData[i].BytesPerRow);
            }
        }
示例#2
0
 private void PlatformConstruct <T>(
     GraphicsDevice graphicsDevice,
     ResourceUploadBatch uploadBatch,
     T[] data,
     uint dataSizeInBytes)
     where T : struct
 {
     DeviceBuffer = AddDisposable(graphicsDevice.Device.CreateBuffer(
                                      data,
                                      MTLResourceOptions.CpuCacheModeDefault));
 }