metal

How to render each pixel of a bitmap texture to each native physical pixel of the screen on macOS?

不羁岁月 提交于 2019-12-02 13:51:11
As modern macOS devices choose to use a scaled HiDPI resolution by default, bitmap images get blurred on screen. Is there a way to render a bitmap pixel by pixel to the true native physical pixels of the display screen? Any CoreGraphics, OpenGL, or metal API that would allow this without change the display mode of the screen? If you are thinking of those convertXXXXToBacking and friends, stop. Here is the explanation for you. A typical 13 in MacBook pro now has native 2560x1600 pixel resolution. The default recommended screen resolution is 1440x900 after fresh macOS install. The user can

Metal RGB to YUV conversion compute shader

孤者浪人 提交于 2019-12-02 08:53:43
问题 I am trying to write a Metal compute shader for converting from RGB to YUV, but am getting build errors. typedef struct { float3x3 matrix; float3 offset; } ColorConversion; // Compute kernel kernel void kernelRGBtoYUV(texture2d<half, access::sample> inputTexture [[ texture(0) ]], texture2d<half, access::write> textureY [[ texture(1) ]], texture2d<half, access::write> textureCbCr [[ texture(2) ]], constant ColorConversion &colorConv [[ buffer(0) ]], uint2 gid [[thread_position_in_grid]]) { //

Metal RGB to YUV conversion compute shader

混江龙づ霸主 提交于 2019-12-02 03:19:33
I am trying to write a Metal compute shader for converting from RGB to YUV, but am getting build errors. typedef struct { float3x3 matrix; float3 offset; } ColorConversion; // Compute kernel kernel void kernelRGBtoYUV(texture2d<half, access::sample> inputTexture [[ texture(0) ]], texture2d<half, access::write> textureY [[ texture(1) ]], texture2d<half, access::write> textureCbCr [[ texture(2) ]], constant ColorConversion &colorConv [[ buffer(0) ]], uint2 gid [[thread_position_in_grid]]) { // Make sure we don't read or write outside of the texture if ((gid.x >= inputTexture.get_width()) || (gid

Display JPEG image using MTKView

邮差的信 提交于 2019-12-02 01:49:42
Is there a way to display JPEG image via MTKView and MTLBuffer(and within iPhone 6+). I've tried this in a following way(this was just test): - (id<MTLBuffer>)testBuffer { if (!_testBuffer) { // NSString *path = [[NSBundle mainBundle] pathForResource:@"testImage" ofType:@"jpg"]; NSData *imageData = [NSData dataWithContentsOfFile:path]; _testBuffer = [self.device newBufferWithBytes:imageData.bytes length:imageData.length options:MTLResourceCPUCacheModeWriteCombined]; } return _testBuffer; } - (void)drawInMTKView:(MTKView *)view { MTLRenderPassDescriptor* renderPassDescriptor = view

newComputePipelineStateWithFunction failed

本秂侑毒 提交于 2019-12-01 15:27:35
I am trying to let a neural net run on metal. The basic idea is that of data duplication. Each gpu thread runs one version of the net for random data points. I have written other shaders that work fine. I also tried my code in a c++ command line app. No errors there. There is also no compile error. I used the apple documentation to convert to metal c++, since not everything from c++11 is supported. It crashes after it loads the kernel function and when it tries to assign newComputePipelineStateWithFunction to the metal device. This means there is a problem with the code that isn't caught at

newComputePipelineStateWithFunction failed

点点圈 提交于 2019-12-01 14:18:39
问题 I am trying to let a neural net run on metal. The basic idea is that of data duplication. Each gpu thread runs one version of the net for random data points. I have written other shaders that work fine. I also tried my code in a c++ command line app. No errors there. There is also no compile error. I used the apple documentation to convert to metal c++, since not everything from c++11 is supported. It crashes after it loads the kernel function and when it tries to assign

Jet: draw_indexed: Crash on iOS 9.2 device

北战南征 提交于 2019-12-01 12:23:26
I am seeing this crash when adding a SKEmitterNode to a scene. Is there anyway to control the "index" through the interface or is it a Metal bug? I tried setting YES to the PrefersOpenGL flag in the info.plist, but it doesnt work. 2015-12-19 22:49:41.967 appname[4190:1827024] Jet: draw_indexed: indexType must be 'unsigned_int' or 'unsigned_short' Assertion failed: (indexType == jet_component_type_unsigned_int || indexType == jet_component_type_unsigned_short), function draw_indexed, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/Jet/Jet-1.50.1/Jet/jet_context_Metal.mm, line 1275. 来源:

Jet: draw_indexed: Crash on iOS 9.2 device

隐身守侯 提交于 2019-12-01 11:34:03
问题 I am seeing this crash when adding a SKEmitterNode to a scene. Is there anyway to control the "index" through the interface or is it a Metal bug? I tried setting YES to the PrefersOpenGL flag in the info.plist, but it doesnt work. 2015-12-19 22:49:41.967 appname[4190:1827024] Jet: draw_indexed: indexType must be 'unsigned_int' or 'unsigned_short' Assertion failed: (indexType == jet_component_type_unsigned_int || indexType == jet_component_type_unsigned_short), function draw_indexed, file

Allocating memory for data used by MTLBuffer in iOS Metal

百般思念 提交于 2019-12-01 05:57:10
As a follow-up question to this answer . I am trying to replace a for-loop running on CPU with a kernel function in Metal to parallelize computation and speed up performance. My function is basically a convolution. Since I repeatedly receive new data for my input array values (the data stems from a AVCaptureSession ) it seems that using newBufferWithBytesNoCopy:length:options:deallocator: is the sensible option for creating the MTLBuffer objects. Here is the relevant code: id <MTLBuffer> dataBuffer = [device newBufferWithBytesNoCopy:dataVector length:sizeof(dataVector) options

How to move a rotated SCNNode in SceneKit?

喜欢而已 提交于 2019-12-01 04:21:21
The image below shows a rotated box that should be moved horizontally on the X and Z axes. Y should stay unaffected to simplify the scenario. The box could also be the SCNNode of the camera, so I guess a projection does not make sense at this point. So lets say we want to move the box in the direction of the red arrow. How to achieve this using SceneKit? The red arrow indicates -Z direction of the box. It also shows us it is not parallel to the camera's projection or to the global axes that are shown as dark grey lines of the grid. My last approach is the product of a translation matrix and a