@@ -47,6 +47,30 @@ public protocol C7FilterProtocol: Mirrorable {
4747
4848 /// The resize of the output texture.
4949 func resize( input size: C7Size ) -> C7Size
50+
51+ /// Special type of parameter factor, such as 4x4 matrix
52+ /// It is recommended to pass the parameters directly. Don't use this function if you have to.
53+ ///
54+ /// - Parameters:
55+ /// - encoder: encoder, can be parallel computation encoder, can also be render 3D encoder
56+ /// - index: Current parameter factor, after use please directly add, Please refer to the `C7ColorMatrix4x4`
57+ func setupSpecialFactors( for encoder: MTLCommandEncoder , index: Int )
58+
59+ /// If you need to replace the subsequent input source texture, return to a new texture with copied to dest.
60+ /// - Parameters:
61+ /// - buffer: A valid MTLCommandBuffer to receive the encoded filter.
62+ /// - texture: Original input texture.
63+ /// - texture2: The final output texture, This parameter is mainly provided for copied new textures to use.
64+ /// - Returns: A new texture with copied to dest.
65+ func combinationBegin( for buffer: MTLCommandBuffer , source texture: MTLTexture , dest texture2: MTLTexture ) throws -> MTLTexture
66+
67+ /// Combination output metal texture, support `compute`, `render` and `mps` type.
68+ /// - Parameters:
69+ /// - buffer: A valid MTLCommandBuffer to receive the encoded filter.
70+ /// - texture: The output metal texture of the first filter.
71+ /// - texture2: Original input texture.
72+ /// - Returns: Metal texture after combined filter treatment.
73+ func combinationAfter( for buffer: MTLCommandBuffer , input texture: MTLTexture , source texture2: MTLTexture ) throws -> MTLTexture
5074}
5175
5276extension C7FilterProtocol {
@@ -56,7 +80,19 @@ extension C7FilterProtocol {
5680 public var otherInputTextures : C7InputTextures { [ ] }
5781 /// The resize of the output texture.
5882 public func resize( input size: C7Size ) -> C7Size { size }
59-
83+ /// Special type of parameter factor, such as 4x4 matrix.
84+ public func setupSpecialFactors( for encoder: MTLCommandEncoder , index: Int ) { }
85+ /// If you need to replace the subsequent input source texture, return to a new texture with copied to dest.
86+ public func combinationBegin( for buffer: MTLCommandBuffer , source texture: MTLTexture , dest texture2: MTLTexture ) throws -> MTLTexture {
87+ return texture
88+ }
89+ /// Combination output metal texture, support `compute`, `render` and `mps` type.
90+ public func combinationAfter( for buffer: MTLCommandBuffer , input texture: MTLTexture , source texture2: MTLTexture ) throws -> MTLTexture {
91+ return texture
92+ }
93+ }
94+
95+ extension C7FilterProtocol {
6096 /// Add the filter into the output texture with compute, render and mps filter.
6197 /// - Parameters:
6298 /// - texture: Input metal texture.
@@ -83,17 +119,6 @@ extension C7FilterProtocol {
83119 }
84120}
85121
86- // MARK: - compute filter protocol
87- public protocol ComputeProtocol : C7FilterProtocol {
88- /// Special type of parameter factor, such as 4x4 matrix
89- /// It is recommended to pass the parameters directly. Don't use this function if you have to.
90- ///
91- /// - Parameters:
92- /// - encoder: encoder, can be parallel computation encoder, can also be render 3D encoder
93- /// - index: Current parameter factor, after use please directly add, Please refer to the `C7ColorMatrix4x4`
94- func setupSpecialFactors( for encoder: MTLCommandEncoder , index: Int )
95- }
96-
97122// MARK: - coreimage filter protocol
98123public protocol CoreImageProtocol : C7FilterProtocol {
99124 /// Compatible with CoreImage.
@@ -127,33 +152,3 @@ public protocol MPSKernelProtocol: C7FilterProtocol {
127152 /// - Returns: Return output metal texture.
128153 func encode( commandBuffer: MTLCommandBuffer , textures: [ MTLTexture ] ) throws -> MTLTexture
129154}
130-
131- // MARK: - combination filter protocol
132- public protocol CombinationProtocol : C7FilterProtocol {
133-
134- /// If you need to replace the subsequent input source texture, return to a new texture with copied to dest.
135- /// - Parameters:
136- /// - buffer: A valid MTLCommandBuffer to receive the encoded filter.
137- /// - texture: Original input texture.
138- /// - texture2: The final output texture, This parameter is mainly provided for copied new textures to use.
139- /// - Returns: A new texture with copied to dest.
140- func combinationBegin( for buffer: MTLCommandBuffer , source texture: MTLTexture , dest texture2: MTLTexture ) throws -> MTLTexture
141-
142- /// Combination output metal texture, support `compute`, `render` and `mps` type.
143- /// - Parameters:
144- /// - buffer: A valid MTLCommandBuffer to receive the encoded filter.
145- /// - texture: The output metal texture of the first filter.
146- /// - texture2: Original input texture.
147- /// - Returns: Metal texture after combined filter treatment.
148- func combinationAfter( for buffer: MTLCommandBuffer , input texture: MTLTexture , source texture2: MTLTexture ) throws -> MTLTexture
149- }
150-
151- extension CombinationProtocol {
152- public func combinationBegin( for buffer: MTLCommandBuffer , source texture: MTLTexture , dest texture2: MTLTexture ) throws -> MTLTexture {
153- return texture
154- }
155-
156- public func combinationAfter( for buffer: MTLCommandBuffer , input texture: MTLTexture , source texture2: MTLTexture ) throws -> MTLTexture {
157- return texture
158- }
159- }
0 commit comments