#include <Metal/Metal.h>

MTLPixelFormat GetMetalPixelFormat(texture_format format) {
    switch (format) {
        // 8-bit formats
        case texture_format::R8_UNORM:
            return MTLPixelFormatR8Unorm;
        case texture_format::R8_SNORM:
            return MTLPixelFormatR8Snorm;
        case texture_format::R8_UINT:
            return MTLPixelFormatR8Uint;
        case texture_format::R8_SINT:
            return MTLPixelFormatR8Sint;

        // 16-bit formats
        case texture_format::RG8_UNORM:
            return MTLPixelFormatRG8Unorm;
        case texture_format::RG8_SNORM:
            return MTLPixelFormatRG8Snorm;
        case texture_format::RG8_UINT:
            return MTLPixelFormatRG8Uint;
        case texture_format::RG8_SINT:
            return MTLPixelFormatRG8Sint;

        // 24-bit formats
        case texture_format::RGB8_UNORM:
            return MTLPixelFormatRGB8Unorm;
        case texture_format::RGB8_SNORM:
            return MTLPixelFormatRGB8Snorm;
        case texture_format::RGB8_UINT:
            return MTLPixelFormatRGB8Uint;
        case texture_format::RGB8_SINT:
            return MTLPixelFormatRGB8Sint;

        // 32-bit formats
        case texture_format::RGBA8_UNORM:
            return MTLPixelFormatRGBA8Unorm;
        case texture_format::RGBA8_SNORM:
            return MTLPixelFormatRGBA8Snorm;
        case texture_format::RGBA8_UINT:
            return MTLPixelFormatRGBA8Uint;
        case texture_format::RGBA8_SINT:
            return MTLPixelFormatRGBA8Sint;

        // SRGB formats
        case texture_format::SRGB8:
            return MTLPixelFormatBGRA8Unorm_sRGB;
        case texture_format::SRGB8_ALPHA8:
            return MTLPixelFormatRGBA8Unorm_sRGB;

        // 16-bit float formats
        case texture_format::R16_FLOAT:
            return MTLPixelFormatR16Float;
        case texture_format::RG16_FLOAT:
            return MTLPixelFormatRG16Float;
        case texture_format::RGBA16_FLOAT:
            return MTLPixelFormatRGBA16Float;

        // 32-bit float formats
        case texture_format::R32_FLOAT:
            return MTLPixelFormatR32Float;
        case texture_format::RG32_FLOAT:
            return MTLPixelFormatRG32Float;
        case texture_format::RGBA32_FLOAT:
            return MTLPixelFormatRGBA32Float;

        // Integer formats
        case texture_format::R16_UINT:
            return MTLPixelFormatR16Uint;
        case texture_format::R16_SINT:
            return MTLPixelFormatR16Sint;
        case texture_format::RG16_UINT:
            return MTLPixelFormatRG16Uint;
        case texture_format::RG16_SINT:
            return MTLPixelFormatRG16Sint;
        case texture_format::RGBA16_UINT:
            return MTLPixelFormatRGBA16Uint;
        case texture_format::RGBA16_SINT:
            return MTLPixelFormatRGBA16Sint;
        case texture_format::R32_UINT:
            return MTLPixelFormatR32Uint;
        case texture_format::R32_SINT:
            return MTLPixelFormatR32Sint;
        case texture_format::RG32_UINT:
            return MTLPixelFormatRG32Uint;
        case texture_format::RG32_SINT:
            return MTLPixelFormatRG32Sint;
        case texture_format::RGBA32_UINT:
            return MTLPixelFormatRGBA32Uint;
        case texture_format::RGBA32_SINT:
            return MTLPixelFormatRGBA32Sint;

        // Depth/stencil formats
        case texture_format::D16_UNORM:
            return MTLPixelFormatDepth16Unorm;
        case texture_format::D24_UNORM_S8_UINT:
            return MTLPixelFormatDepth24Unorm_Stencil8;
        case texture_format::D32_FLOAT:
            return MTLPixelFormatDepth32Float;
        case texture_format::D32_FLOAT_S8X24_UINT:
            return MTLPixelFormatDepth32Float_Stencil8;

        // Compressed formats
        case texture_format::BC1_UNORM:
            return MTLPixelFormatBC1_RGBA;
        case texture_format::BC3_UNORM:
            return MTLPixelFormatBC3_RGBA;
        
        default:
            return MTLPixelFormatInvalid; // Unsupported format
    }
}
