Итак, я пытался запустить несколько ядер MPS. Основываясь на моем предыдущем вопросе здесь: MPSImageIntegral возвращает все нули
где я пытался запустить MPSImageIntegral на значениях с плавающей точкой. Теперь я перешел к uint32_t
значениям. Но получается, что я всегда получаю утверждение
/ BuildRoot / Библиотека / кэши / com.apple.xbs / Источники / MetalPerformanceShaders / MetalPerformanceShaders-121.4.2 / MPSImage / Фильтры / MPSIntegral.mm: 196:
Не удалось проверить утверждение. `Формат текстуры назначения 0x600003b62760 не
источник совпадения 0x600003b62680 в формате текстуры '
Утверждение вводит в заблуждение, так как мои типы текстур не являются несоответствием.
Это то, что я делаю, чтобы создать MTLTexture
+ (id<MTLTexture>) createTestTexture: (float)val metalDevice:(id<MTLDevice>)device textureWidth:(int)widthTex
{
std::vector<uint32_t> testData;
for(int i = 0; i < widthTex; i++)
testData.push_back(i);
MTLTextureDescriptor* desc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatR32Uint
width: widthTex height:1 mipmapped:NO];
[desc setResourceOptions:MTLResourceStorageModeManaged];
[desc setStorageMode:MTLStorageModeManaged];
[desc setUsage:(MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite)];
id<MTLTexture> tex = [device newTextureWithDescriptor:desc];
MTLRegion texDataRegion = MTLRegionMake2D(0, 0, widthTex, 1);
[tex replaceRegion:texDataRegion mipmapLevel:0 withBytes:testData.data() bytesPerRow:1024];
return tex;
}
Это функция, которую я использую для создания текстуры ввода и вывода.
Затем я продолжаю запускать мой MPSImageIntegral следующим образом:
id<MTLTexture> inTex = [ViewController createTestTexture:1.0f metalDevice:_device textureWidth:100];
id<MTLTexture> outTex = [ViewController createTestTexture:1.0f metalDevice:_device textureWidth:100];
id<MTLCommandQueue> _commandQueue = [_device newCommandQueue];
id<MTLCommandBuffer> commandBuffer = [_commandQueue commandBuffer];
// Create a MPS filter.
[integral encodeToCommandBuffer:commandBuffer sourceTexture:inTex destinationTexture:outTex];
На основании документации здесь: https://developer.apple.com/documentation/metalperformanceshaders/image_filters?language=objc
MPSImageIntegral
поддерживает MTLPixelFormatR32Uint
, что-то не так делаю, что я тут делаю?