From 69c77800d955c7d94923479687293d6adb18c53a Mon Sep 17 00:00:00 2001 From: Rosie Wang Date: Wed, 18 Sep 2024 00:27:05 -0400 Subject: [PATCH] Fix RGB_to_RGBA --- src/libutils/oglapphelpers/msl.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libutils/oglapphelpers/msl.mm b/src/libutils/oglapphelpers/msl.mm index 899e94ec34..3923b809a1 100644 --- a/src/libutils/oglapphelpers/msl.mm +++ b/src/libutils/oglapphelpers/msl.mm @@ -75,9 +75,8 @@ void RGB_to_RGBA(const float* lutValues, int valueCount, std::vector& flo throw Exception("Missing texture data"); } - // MTLPixelFormatRGB32Float not supported on metal. Adapt to MTLPixelFormatRGBA32Float std::vector float4AdaptedLutValues; - RGB_to_RGBA(lutValues, 3*edgelen*edgelen*edgelen, float4AdaptedLutValues); + memcpy(float4AdaptedLutValues.data(), lutValues, 4 * edgelen*edgelen*edgelen * sizeof(float)); MTLTextureDescriptor* texDescriptor = [MTLTextureDescriptor new]; @@ -123,7 +122,8 @@ void RGB_to_RGBA(const float* lutValues, int valueCount, std::vector& flo } else { - RGB_to_RGBA(values, 3*width*height, adaptedLutValues); + adaptedLutValues.resize(4 * width * height); + memcpy(adaptedLutValues.data(), values, 4 * width * height * sizeof(float)); } MTLTextureDescriptor* texDescriptor = [MTLTextureDescriptor new];