@@ -135,7 +135,7 @@ class MyRenderer: ShaderRenderer {
135
135
override func draw (view : MTKView, drawable : CAMetalDrawable) {
136
136
let dispatch = EMMetalDispatch ()
137
137
dispatch.compute { [self ] encoder in
138
- compute.tex = EMMetalTexture ( texture : drawable.texture )
138
+ compute.tex = drawable.texture . emTexture
139
139
compute.col = abs (sin (Float (Date ().timeIntervalSince (date)))) * 0.9
140
140
compute.dispatch (encoder, textureSizeReference : drawable.texture )
141
141
}
@@ -172,7 +172,7 @@ You can manually dispatch compute or render functions outside of MTKView.
172
172
let tex = EMMetalTexture.create (width : 100 , height : 100 , pixelFormat : .bgra8Unorm , label : " tex" , usage : .read_write )
173
173
let dispatch = EMMetalDispatch ()
174
174
dispatch.compute { encoder in
175
- compute.tex = EMMetalTexture ( texture : tex)
175
+ compute.tex = tex. emTexture
176
176
compute.col = 0.5
177
177
compute.dispatch (encoder, textureSizeReference : tex)
178
178
}
@@ -205,6 +205,19 @@ dispatch.custom { commandBuffer in
205
205
dispatch.commit ()
206
206
```
207
207
208
+ ### Custom Metal Functions
209
+
210
+ override customMetalCode property to add your original metal codes.
211
+
212
+ ``` .swift
213
+ @ShaderStringBuilder
214
+ override var customMetalCode: String {
215
+ " inline float myFunc() {"
216
+ " return 1.0;"
217
+ " }"
218
+ }
219
+ ```
220
+
208
221
## Sample Code
209
222
210
223
@@ -263,7 +276,7 @@ class MyRenderer: ShaderRenderer {
263
276
override func draw (view : MTKView, drawable : CAMetalDrawable) {
264
277
let dispatch = EMMetalDispatch ()
265
278
dispatch.compute { [self ] encoder in
266
- compute.tex = EMMetalTexture ( texture : drawable.texture )
279
+ compute.tex = drawable.texture . emTexture
267
280
compute.intensity = abs (sin (Float (Date ().timeIntervalSince (date)))) * 100
268
281
compute.dispatch (encoder, textureSizeReference : drawable.texture )
269
282
}
0 commit comments