mtlbuffer

MTKView texture correct color build-up

我与影子孤独终老i 提交于 2020-01-24 01:03:30
问题 I am working on a metal-backed drawing application where brushstrokes are drawn on an MTKView by stamping a textured square repeatedly along a path. I am having color-accumulation issues as illustrated with the picture below: For alpha values [0.5 - 1.0] the results are more or less what I expect. However, for small alpha values, the result looks patchy and never achieves the uniform/correctly saturated value of the original fully opaque brush color (i.e. like the top brushstroke in above

MTLBuffer allocation + CPU/GPU synchronisation

二次信任 提交于 2019-12-23 04:47:45
问题 I am using a metal performance shader( MPSImageHistogram ) to compute something in an MTLBuffer that I grab, perform computations, and then display via MTKView . The MTLBuffer output from the shader is small (~4K bytes). So I am allocating a new MTLBuffer object for every render pass, and there are atleast 30 renders per second for every video frame. calculation = MPSImageHistogram(device: device, histogramInfo: &histogramInfo) let bufferLength = calculation.histogramSize(forSourceFormat:

how to display MTKView with rgba16Float MTLPixelFormat

可紊 提交于 2019-12-20 04:54:25
问题 I have an MTKView set to use MTLPixelFormat.rgba16Float. I'm having display issues which can be best described with the following graphic: So the intended UIColor becomes washed out, but only while it is being displayed in MTKView. When I convert the drawable texture back to an image for display in a UIView via CIIMage, I get back the original color. Here is how I create that output: let colorSpace = CGColorSpaceCreateDeviceRGB() let kciOptions = [kCIImageColorSpace: colorSpace,

MTKView blend issues when re-using currentDrawable.texture in draw() loop

最后都变了- 提交于 2019-12-11 17:12:09
问题 I am working on a metal-backed painting application in which I divide the drawing of a stroke in two steps: the first step draws the leading edge of a stroke to screen and captures the entire to an MTLTexture via: metalTextureComposite = self.currentDrawable!.texture the second step draws an updated leading edge of the advancing stroke, and composites atop a polygon textured with the last saved metalTextureComposite. This method allows me to draw infinitely long strokes without sacrificing