feat: add vertical canvas editors and host-owned scopes LUT workspace; boundary review in progress
这个提交包含在:
1 父节点
0dfb838b39
当前提交
031c704f0f
29 个文件已更改
+1062
-234
没有与搜索条件相匹配的文件
@@ -0,0 +1,18 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Metal/Metal.h>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
struct Pixel{float r,g,b,a;};
|
||||
int main(int argc,const char **argv){@autoreleasepool{
|
||||
assert(argc==2);id<MTLDevice>device=MTLCreateSystemDefaultDevice();assert(device);NSError *error=nil;id<MTLLibrary>lib=[device newLibraryWithURL:[NSURL fileURLWithPath:@(argv[1])] error:&error];assert(lib);
|
||||
id<MTLComputePipelineState>pipeline=[device newComputePipelineStateWithFunction:[lib newFunctionWithName:@"dyScopeSample"] error:&error];assert(pipeline);
|
||||
auto td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float width:2 height:2 mipmapped:NO];td.storageMode=MTLStorageModeShared;td.usage=MTLTextureUsageShaderRead;id<MTLTexture>source=[device newTextureWithDescriptor:td];
|
||||
Pixel pixels[]={{4,-.25,.5,.5},{0,1,0,1},{0,0,1,1},{NAN,0,0,0}};[source replaceRegion:MTLRegionMake2D(0,0,2,2) mipmapLevel:0 withBytes:pixels bytesPerRow:sizeof(Pixel)*2];
|
||||
id<MTLBuffer>buffer=[device newBufferWithLength:320*180*sizeof(Pixel) options:MTLResourceStorageModeShared];id<MTLCommandQueue>queue=[device newCommandQueue];
|
||||
for(uint32_t flip=0;flip<2;flip++){
|
||||
auto cb=[queue commandBuffer];auto ce=[cb computeCommandEncoder];[ce setComputePipelineState:pipeline];[ce setTexture:source atIndex:0];[ce setBuffer:buffer offset:0 atIndex:0];[ce setBytes:&flip length:4 atIndex:1];[ce dispatchThreads:MTLSizeMake(320,180,1) threadsPerThreadgroup:MTLSizeMake(8,8,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];assert(cb.status==MTLCommandBufferStatusCompleted);
|
||||
auto result=(const Pixel*)buffer.contents;if(!flip){assert(result[0].r==4&&result[0].g==-.25f&&result[0].a==.5f);assert(result[319].g==1);assert(result[179*320].b==1);assert(std::isnan(result[180*320-1].r));}
|
||||
else{assert(result[0].b==1);assert(std::isnan(result[319].r));assert(result[179*320].r==4&&result[179*320].a==.5f);assert(result[180*320-1].g==1);}
|
||||
}
|
||||
return 0;
|
||||
}}
|
||||
在新工单中引用
屏蔽一个用户