(macos) add isStencil argument for creating depth texture on macOS (if true, creates texture with .depth24Unorm_stencil8
This commit is contained in:
@@ -310,7 +310,7 @@ SWIFT_CLASS("_TtC12swift_module20ThermionTextureSwift")
|
|||||||
@property (nonatomic, strong) id <MTLTexture> _Nullable metalTexture;
|
@property (nonatomic, strong) id <MTLTexture> _Nullable metalTexture;
|
||||||
@property (nonatomic) NSInteger metalTextureAddress;
|
@property (nonatomic) NSInteger metalTextureAddress;
|
||||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
||||||
- (nonnull instancetype)initWithWidth:(int64_t)width height:(int64_t)height isDepth:(BOOL)isDepth OBJC_DESIGNATED_INITIALIZER;
|
- (nonnull instancetype)initWithWidth:(int64_t)width height:(int64_t)height isDepth:(BOOL)isDepth isStencil:(BOOL)isStencil OBJC_DESIGNATED_INITIALIZER;
|
||||||
- (void)destroyTexture;
|
- (void)destroyTexture;
|
||||||
- (BOOL)fillWithPNGImageWithImageURL:(NSURL * _Nonnull)imageURL SWIFT_WARN_UNUSED_RESULT;
|
- (BOOL)fillWithPNGImageWithImageURL:(NSURL * _Nonnull)imageURL SWIFT_WARN_UNUSED_RESULT;
|
||||||
- (void)fillColor;
|
- (void)fillColor;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import GLKit
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public init(width:Int64, height:Int64, isDepth:Bool) {
|
@objc public init(width:Int64, height:Int64, isDepth:Bool, isStencil:Bool) {
|
||||||
if(self.metalDevice == nil) {
|
if(self.metalDevice == nil) {
|
||||||
self.metalDevice = MTLCreateSystemDefaultDevice()!
|
self.metalDevice = MTLCreateSystemDefaultDevice()!
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ import GLKit
|
|||||||
print("Creating depth texture")
|
print("Creating depth texture")
|
||||||
// Create a proper depth texture without IOSurface backing
|
// Create a proper depth texture without IOSurface backing
|
||||||
let textureDescriptor = MTLTextureDescriptor.texture2DDescriptor(
|
let textureDescriptor = MTLTextureDescriptor.texture2DDescriptor(
|
||||||
pixelFormat: .depth32Float,
|
pixelFormat: isStencil ? .depth24Unorm_stencil8 : .depth32Float_stencil8,
|
||||||
width: Int(width),
|
width: Int(width),
|
||||||
height: Int(height),
|
height: Int(height),
|
||||||
mipmapped: false)
|
mipmapped: false)
|
||||||
@@ -45,9 +45,6 @@ import GLKit
|
|||||||
|
|
||||||
print("Creating color texture")
|
print("Creating color texture")
|
||||||
|
|
||||||
|
|
||||||
// let pixelFormat: MTLPixelFormat = isDepth ? .depth32Float : .bgra8Unorm
|
|
||||||
// let cvPixelFormat = isDepth ? kCVPixelFormatType_DepthFloat32 : kCVPixelFormatType_32BGRA
|
|
||||||
|
|
||||||
if(CVPixelBufferCreate(kCFAllocatorDefault, Int(width), Int(height),
|
if(CVPixelBufferCreate(kCFAllocatorDefault, Int(width), Int(height),
|
||||||
kCVPixelFormatType_32BGRA, pixelBufferAttrs, &pixelBuffer) != kCVReturnSuccess) {
|
kCVPixelFormatType_32BGRA, pixelBufferAttrs, &pixelBuffer) != kCVReturnSuccess) {
|
||||||
|
|||||||
Reference in New Issue
Block a user