MTLRenderPipelineDescriptor.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using static Veldrid.MetalBindings.ObjectiveCRuntime;
  2. using System;
  3. using System.Runtime.InteropServices;
  4. namespace Veldrid.MetalBindings
  5. {
  6. [StructLayout(LayoutKind.Sequential)]
  7. public struct MTLRenderPipelineDescriptor
  8. {
  9. public readonly IntPtr NativePtr;
  10. public MTLRenderPipelineDescriptor(IntPtr ptr) => NativePtr = ptr;
  11. public static MTLRenderPipelineDescriptor New()
  12. {
  13. var cls = new ObjCClass("MTLRenderPipelineDescriptor");
  14. var ret = cls.AllocInit<MTLRenderPipelineDescriptor>();
  15. return ret;
  16. }
  17. public MTLFunction vertexFunction
  18. {
  19. get => objc_msgSend<MTLFunction>(NativePtr, sel_vertexFunction);
  20. set => objc_msgSend(NativePtr, sel_setVertexFunction, value.NativePtr);
  21. }
  22. public MTLFunction fragmentFunction
  23. {
  24. get => objc_msgSend<MTLFunction>(NativePtr, sel_fragmentFunction);
  25. set => objc_msgSend(NativePtr, sel_setFragmentFunction, value.NativePtr);
  26. }
  27. public MTLRenderPipelineColorAttachmentDescriptorArray colorAttachments
  28. => objc_msgSend<MTLRenderPipelineColorAttachmentDescriptorArray>(NativePtr, sel_colorAttachments);
  29. public MTLPixelFormat depthAttachmentPixelFormat
  30. {
  31. get => (MTLPixelFormat)uint_objc_msgSend(NativePtr, sel_depthAttachmentPixelFormat);
  32. set => objc_msgSend(NativePtr, sel_setDepthAttachmentPixelFormat, (uint)value);
  33. }
  34. public MTLPixelFormat stencilAttachmentPixelFormat
  35. {
  36. get => (MTLPixelFormat)uint_objc_msgSend(NativePtr, sel_stencilAttachmentPixelFormat);
  37. set => objc_msgSend(NativePtr, sel_setStencilAttachmentPixelFormat, (uint)value);
  38. }
  39. public UIntPtr sampleCount
  40. {
  41. get => UIntPtr_objc_msgSend(NativePtr, sel_sampleCount);
  42. set => objc_msgSend(NativePtr, sel_setSampleCount, value);
  43. }
  44. public MTLVertexDescriptor vertexDescriptor => objc_msgSend<MTLVertexDescriptor>(NativePtr, sel_vertexDescriptor);
  45. public Bool8 alphaToCoverageEnabled
  46. {
  47. get => bool8_objc_msgSend(NativePtr, sel_isAlphaToCoverageEnabled);
  48. set => objc_msgSend(NativePtr, sel_setAlphaToCoverageEnabled, value);
  49. }
  50. private static readonly Selector sel_vertexFunction = "vertexFunction";
  51. private static readonly Selector sel_setVertexFunction = "setVertexFunction:";
  52. private static readonly Selector sel_fragmentFunction = "fragmentFunction";
  53. private static readonly Selector sel_setFragmentFunction = "setFragmentFunction:";
  54. private static readonly Selector sel_colorAttachments = "colorAttachments";
  55. private static readonly Selector sel_depthAttachmentPixelFormat = "depthAttachmentPixelFormat";
  56. private static readonly Selector sel_setDepthAttachmentPixelFormat = "setDepthAttachmentPixelFormat:";
  57. private static readonly Selector sel_stencilAttachmentPixelFormat = "stencilAttachmentPixelFormat";
  58. private static readonly Selector sel_setStencilAttachmentPixelFormat = "setStencilAttachmentPixelFormat:";
  59. private static readonly Selector sel_sampleCount = "sampleCount";
  60. private static readonly Selector sel_setSampleCount = "setSampleCount:";
  61. private static readonly Selector sel_vertexDescriptor = "vertexDescriptor";
  62. private static readonly Selector sel_isAlphaToCoverageEnabled = "isAlphaToCoverageEnabled";
  63. private static readonly Selector sel_setAlphaToCoverageEnabled = "setAlphaToCoverageEnabled:";
  64. }
  65. }