public void GetBufferMemoryRequirements(IMgBuffer buffer, out MgMemoryRequirements pMemoryRequirements) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } var bBuffer = (AmtBuffer)buffer; var alignment = 16UL; // TODO: constant buffer alignment should be 256 //if ((bBuffer.Usage & MgBufferUsageFlagBits.UNIFORM_BUFFER_BIT) == MgBufferUsageFlagBits.UNIFORM_BUFFER_BIT) //{ // https://developer.apple.com/reference/metal/mtlrendercommandencoder/1515829-setvertexbuffer // For buffers in the device address space, the offset must be aligned to the data type consumed by the // vertex shader function (which is always less than or equal to 16 bytes). // NOTE : VERTEX BUFFER data offset must be <= 16 bytes // For buffers in the constant address space, the offset must be aligned to 256 bytes in macOS. In // iOS, the offset must be aligned to the maximum of either the data type consumed by the vertex shader // function, or 4 bytes.A 16 - byte alignment is always safe in iOS if you do not need to worry // about the data type. // NOTE : constant/uniform (i.e. readonly) buffer on macOS should be in 256 byte increments, constant on iOS // must be >= 16 bytes or max //} pMemoryRequirements = new MgMemoryRequirements { Size = (ulong)bBuffer.Length, MemoryTypeBits = 1 << 0, Alignment = alignment, }; }
public void GetBufferMemoryRequirements(IMgBuffer buffer, out MgMemoryRequirements pMemoryRequirements) { var impl = buffer as MockBuffer; pMemoryRequirements = new MgMemoryRequirements(); if (impl != null) { pMemoryRequirements.MemoryTypeBits = 0; pMemoryRequirements.Size = impl.BufferSize; } }
public void GetBufferMemoryRequirements(IMgBuffer buffer, out MgMemoryRequirements pMemoryRequirements) { var internalBuffer = buffer as IGLBuffer; if (internalBuffer == null) { throw new ArgumentException(nameof(buffer)); } uint mask = DetermineBufferMemoryType(internalBuffer.Usage); pMemoryRequirements = new MgMemoryRequirements { Size = internalBuffer.RequestedSize, MemoryTypeBits = mask, }; }
public void GetImageMemoryRequirements(IMgImage image, out MgMemoryRequirements memoryRequirements) { throw new NotImplementedException(); }
public void GetBufferMemoryRequirements(IMgBuffer buffer, out MgMemoryRequirements pMemoryRequirements) { throw new NotImplementedException(); }
public void GetImageMemoryRequirements(IMgImage image, out MgMemoryRequirements memoryRequirements) { if (image == null) { throw new ArgumentNullException(nameof(image)); } var texture = (IGLImage)image; uint imageSize = 0; uint width = (uint)texture.Width; uint height = (uint)texture.Height; uint size = Math.Max(width, height); for (int i = 0; i < texture.Levels; ++i) { Debug.Assert(size >= 1); var format = texture.Format; switch (format) { // 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: imageSize += ((width + 3) / 4) * ((height + 3) / 4) * GetSize(format); break; default: imageSize += GetSize(format) * width * height; break; //return Result.ERROR_FEATURE_NOT_PRESENT; } if (width > 1) { width = width / 2; } if (height > 1) { height = height / 2; } } memoryRequirements = new MgMemoryRequirements { // HOST ONLY OR DEVICE MemoryTypeBits = GLMemoryBufferType.IMAGE.GetMask(), Size = imageSize, }; }