Page 1 of 1

BRAW SDK: IBlackmagicRawPipelineIterator

PostPosted: Thu Sep 10, 2020 5:35 pm
by fnordware
It seems like in the ProcessClipMetal.mm example I should be able to replace the Metal setup stuff (everything between factory->CreateCodec() and codec->OpenClip()) with something like this:

Code: Select all
      bool pipelineSet = false;
      
      IBlackmagicRawPipelineIterator *pipelineIterator = nullptr;
      result = factory->CreatePipelineIterator(blackmagicRawInteropOpenGL, &pipelineIterator);

      do
      {
         BlackmagicRawInterop pipeline_interop = blackmagicRawInteropNone;
         BlackmagicRawPipeline pipeline_pipeline = blackmagicRawPipelineCPU;
         
         result = pipelineIterator->GetInterop(&pipeline_interop);
         result = pipelineIterator->GetPipeline(&pipeline_pipeline);
         
         IBlackmagicRawPipelineDeviceIterator *deviceIterator = nullptr;
         result = factory->CreatePipelineDeviceIterator(pipeline_pipeline, pipeline_interop, &deviceIterator);
         
         do
         {
            BlackmagicRawInterop device_interop = blackmagicRawInteropNone;
            BlackmagicRawPipeline device_pipeline = blackmagicRawPipelineCPU;
            
            result = deviceIterator->GetInterop(&device_interop);
            result = deviceIterator->GetPipeline(&device_pipeline);
            
            if(device_pipeline == blackmagicRawPipelineMetal)
            {
               IBlackmagicRawPipelineDevice *device = nullptr;
               result = deviceIterator->CreateDevice(&device);
            
               IBlackmagicRawConfiguration *config = nullptr;
               result = codec->QueryInterface(IID_IBlackmagicRawConfiguration, (void **)&config);
            
               result = config->SetFromDevice(device);

               pipelineSet = true;
            }
            
         }while(deviceIterator->Next() == S_OK && !pipelineSet);
         
      }while(pipelineIterator->Next() == S_OK && !pipelineSet);



But when I do this, all the frames that come out are black. What am I missing?

Re: BRAW SDK: IBlackmagicRawPipelineIterator

PostPosted: Tue Sep 15, 2020 4:52 am
by CaptainHook
Hi,

Here's a modified version of ProcessClipMetal.mm that processes the image with a Metal device using iterators and saves the resultant buffer to a png file. It demonstrates how to get Metal buffers from the GPU to CPU and how to create and use a device (in a blocking manner).

We will likely update our sample code in the future to this or something similar, thanks!

Re: BRAW SDK: IBlackmagicRawPipelineIterator

PostPosted: Thu Sep 17, 2020 1:45 am
by fnordware
Great, thanks! And here's a version that uses IBlackmagicRawResourceManager, so you don't even need those Metal calls. Note the file has been changed from a .mm to .cpp.

Re: BRAW SDK: IBlackmagicRawPipelineIterator

PostPosted: Thu Sep 17, 2020 5:31 am
by fnordware
fnordware wrote:Great, thanks! And here's a version that uses IBlackmagicRawResourceManager, so you don't even need those Metal calls. Note the file has been changed from a .mm to .cpp.


BTW, it feels like I should be able to swap in OpenCL enums for Metal ones and have a working OpenCL example, but it's not working for me. Ditto for CUDA. Any idea?