This repository has been archived by the owner on Jun 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMTLTexture.cs
46 lines (41 loc) · 1.48 KB
/
MTLTexture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using static Veldrid.MetalBindings.ObjectiveCRuntime;
using System;
using System.Runtime.InteropServices;
namespace Veldrid.MetalBindings
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct MTLTexture
{
public readonly IntPtr NativePtr;
public MTLTexture(IntPtr ptr) => NativePtr = ptr;
public bool IsNull => NativePtr == IntPtr.Zero;
public void replaceRegion(
MTLRegion region,
UIntPtr mipmapLevel,
UIntPtr slice,
void* pixelBytes,
UIntPtr bytesPerRow,
UIntPtr bytesPerImage)
{
objc_msgSend(NativePtr, sel_replaceRegion,
region,
mipmapLevel,
slice,
(IntPtr)pixelBytes,
bytesPerRow,
bytesPerImage);
}
public MTLTexture newTextureView(
MTLPixelFormat pixelFormat,
MTLTextureType textureType,
NSRange levelRange,
NSRange sliceRange)
{
IntPtr ret = IntPtr_objc_msgSend(NativePtr, sel_newTextureView,
(uint)pixelFormat, (uint)textureType, levelRange, sliceRange);
return new MTLTexture(ret);
}
private static readonly Selector sel_replaceRegion = "replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:";
private static readonly Selector sel_newTextureView = "newTextureViewWithPixelFormat:textureType:levels:slices:";
}
}