[SOLVED] BlackmagicRawResourceFormat & MTLPixelFormat

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline
User avatar

Chris Hocking

  • Posts: 704
  • Joined: Wed Aug 22, 2012 4:23 am
  • Location: Melbourne, Australia

[SOLVED] BlackmagicRawResourceFormat & MTLPixelFormat

PostFri Sep 30, 2022 10:26 pm

I'm having trouble matching the 32-bit BlackmagicRawResourceFormat's to their MTLPixelFormat equivalent.

For example:

blackmagicRawResourceFormatRGBAU8 = MTLPixelFormatRGBA8Unorm
blackmagicRawResourceFormatRGBAU16 = MTLPixelFormatRGBA16Unorm
blackmagicRawResourceFormatRGBF32 = ??
blackmagicRawResourceFormatRGBF32Planar = ??
blackmagicRawResourceFormatBGRAF32 = ??

Is there any reason why 8-bit and 16-bit use RGBA, but 32-bit uses just RGB (or BGRA)?

To give some back story, essentially, I'm trying to take the output from the MTLBuffer of the BRAW API, and use it as a texture on a different MTLDevice. I'm only just starting to play with Metal and the BRAW SDK, so apologies if I'm asking something silly. Thanks team!
Last edited by Chris Hocking on Wed Oct 05, 2022 1:15 am, edited 1 time in total.
Offline
User avatar

Chris Hocking

  • Posts: 704
  • Joined: Wed Aug 22, 2012 4:23 am
  • Location: Melbourne, Australia

Re: BlackmagicRawResourceFormat & MTLPixelFormat?

PostWed Oct 05, 2022 1:15 am

For anyone playing along at home, I was able to use
Code: Select all
MTLTextureSwizzleChannels
to solve this issue.

For example:

Code: Select all
MTLTextureSwizzleChannels channels;
   
if (bitDepth == blackmagicRawResourceFormatRGBAU16) {
    //---------------------------------------------------------
    // 16-bit (Unsigned 16bit interleaved RGBA):
    //---------------------------------------------------------
    bitsPerPixel        = 64;
    brawPixelFormat     = MTLPixelFormatRGBA16Unorm;
    bytesPerRow         = (bitsPerPixel * processedImageWidthPixels) / 8U;
    channels            = MTLTextureSwizzleChannelsDefault;
} else if (bitDepth == blackmagicRawResourceFormatBGRAF32) {
    //---------------------------------------------------------
    // 32-bit (Floating point interleaved RGB)
    //---------------------------------------------------------
    bitsPerPixel        = 128;
    brawPixelFormat     = MTLPixelFormatRGBA32Float;
    bytesPerRow         = (bitsPerPixel * processedImageWidthPixels) / 8U;
    channels            = MTLTextureSwizzleChannelsMake(MTLTextureSwizzleBlue, MTLTextureSwizzleGreen, MTLTextureSwizzleRed, MTLTextureSwizzleAlpha);
} else {
    //---------------------------------------------------------
    // 8-bit (Unsigned 8bit interleaved RGBA):
    //---------------------------------------------------------
    bitsPerPixel        = 32;
    brawPixelFormat     = MTLPixelFormatRGBA8Unorm;
    bytesPerRow         = (bitsPerPixel * processedImageWidthPixels) / 8U;
    channels            = MTLTextureSwizzleChannelsDefault;
}

Return to Software Developers

Who is online

Users browsing this forum: TBTech and 18 guests