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?

Re: BRAW SDK: IBlackmagicRawPipelineIterator

PostPosted: Sat Sep 19, 2020 7:59 pm
by Hendrik Proosa
I can’t add anything to this thread but just wanted to thank you both, while reading your code examples, I think I just realized how to actually use the gpu decode and it provided a handle to also get the idea of opengl interop :)

Re: BRAW SDK: IBlackmagicRawPipelineIterator

PostPosted: Wed Sep 23, 2020 10:02 pm
by fnordware
Just wanted to ping this thread again. Seems like the attached example should work to use an OpenCL pipeline, but it doesn't. On one machine it stalls, on another I get a black frame. Both machines (they are Macs, BTW) don't show OpenCL as an available pipeline under blackmagicRawInteropOpenGL, but do have it under blackmagicRawInteropNone. The Metal pipeline works on both.

Re: BRAW SDK: IBlackmagicRawPipelineIterator

PostPosted: Tue Sep 29, 2020 6:09 am
by CaptainHook
Hi, sorry we are really busy at the moment and haven't been able to get back to you on this. We haven't forgotten but it may take us another couple of weeks sorry.

Re: BRAW SDK: IBlackmagicRawPipelineIterator

PostPosted: Thu Nov 12, 2020 7:28 pm
by fnordware
Hi, do you guys have time to look into OpenCL and CUDA pipelines?