From d35ff537dfa70b39e637c202422d5b7a76b3ab03 Mon Sep 17 00:00:00 2001 From: Rosie Wang Date: Fri, 26 Jul 2024 23:42:29 -0400 Subject: [PATCH] Fix { and address code review comments --- src/OpenColorIO/GpuShaderUtils.cpp | 8 ++++++-- src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/OpenColorIO/GpuShaderUtils.cpp b/src/OpenColorIO/GpuShaderUtils.cpp index e4576d0897..3d48e22bba 100644 --- a/src/OpenColorIO/GpuShaderUtils.cpp +++ b/src/OpenColorIO/GpuShaderUtils.cpp @@ -223,9 +223,12 @@ std::string getMatrixValues(const T * mtx, GpuLanguage lang, bool transpose) } -void RGBtoRGBATexture(const float* lutValues, int valueCount, std::vector& float4AdaptedLutValues){ +void RGBtoRGBATexture(const float* lutValues, int valueCount, std::vector& float4AdaptedLutValues) +{ if(valueCount % 3 != 0) + { throw Exception("Value count should be divisible by 3."); + } valueCount = valueCount * 4 / 3; if(lutValues != nullptr) @@ -235,7 +238,8 @@ void RGBtoRGBATexture(const float* lutValues, int valueCount, std::vector float *rgbaLutValuesIt = float4AdaptedLutValues.data(); const float *end = rgbaLutValuesIt + valueCount; - while(rgbaLutValuesIt != end) { + while(rgbaLutValuesIt != end) + { *rgbaLutValuesIt++ = *rgbLutValuesIt++; *rgbaLutValuesIt++ = *rgbLutValuesIt++; *rgbaLutValuesIt++ = *rgbLutValuesIt++; diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp index fd36a7c740..4dc2e28f70 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp @@ -186,9 +186,10 @@ void GetLut1DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, CreatePaddedLutChannels(width, height, lutData->getArray().getValues(), values); channel = GpuShaderCreator::TEXTURE_RGB_CHANNEL; break; - case 4: { + case 4: + { std::vector paddedChannels; - values.reserve(width * height * 3); + paddedChannels.reserve(width * height * 3); CreatePaddedLutChannels(width, height, lutData->getArray().getValues(), paddedChannels); // Insert a place holder alpha channel with value of 1. This is to support RGBA // texture format for Metal shading language.