From ec72563c967ccf9219b61504bc5008bfb25fc867 Mon Sep 17 00:00:00 2001 From: Dark Knight <> Date: Thu, 19 Oct 2023 21:35:20 -0700 Subject: [PATCH] Revert D50436128: Multisect successfully blamed "D50436125: [IGL] Simplify `ShaderUniforms::setFloat3x3`" for test or build failures Summary: This diff is reverting D50436128 Depends on D50483445 D50436125: [IGL] Simplify `ShaderUniforms::setFloat3x3` by AmesingFlank has been identified to be causing the following test or build failures: Tests affected: - [//fbandroid/instrumentation_tests/com/facebook/msqrd:block_inputs_every_type_via_patches-64bit - testDefault[base_gles2_hermes_vEffect_uncompressed] (com.facebook.msqrd.unified_runner.AREngineScreenshotTest)](https://www.internalfb.com/intern/test/281475070193663/) Here's the Multisect link: https://www.internalfb.com/multisect/3348209 Here are the tasks that are relevant to this breakage: We're generating a revert to back out the changes in this diff, please note the backout may land if someone accepts it. If you believe this diff has been generated in error you may Commandeer and Abandon it. Reviewed By: syeh1 Differential Revision: D50483453 fbshipit-source-id: 7052e647820c558d7df6b85bae1969823d9b748e --- IGLU/simple_renderer/ShaderUniforms.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/IGLU/simple_renderer/ShaderUniforms.cpp b/IGLU/simple_renderer/ShaderUniforms.cpp index 46f076192a..27530caecd 100644 --- a/IGLU/simple_renderer/ShaderUniforms.cpp +++ b/IGLU/simple_renderer/ShaderUniforms.cpp @@ -516,7 +516,26 @@ void ShaderUniforms::setFloat3x3Array(const igl::NameHandle& uniformName, const iglu::simdtypes::float3x3* value, size_t count, size_t arrayIndex) { - setUniformBytes(uniformName, value, sizeof(iglu::simdtypes::float3x3), count, arrayIndex); + if (device_.getBackendType() == igl::BackendType::Metal || + device_.getBackendType() == igl::BackendType::Vulkan) { + setUniformBytes(uniformName, value, sizeof(iglu::simdtypes::float3x3), count, arrayIndex); + } else { + // simdtypes::float3x3 has an extra float per float-vector. + // Remove it so we can send the packed version to OpenGL + auto paddedMatrixPtr = reinterpret_cast(value); + auto packedMatrix = new float[9 * count]; + auto packedMatrixPtr = packedMatrix; + for (int n = 0; n < count; n++) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + *packedMatrixPtr++ = *paddedMatrixPtr++; + } + paddedMatrixPtr++; // skip over padded float + } + } + setUniformBytes(uniformName, packedMatrix, sizeof(float) * 9, count, arrayIndex); + delete[] packedMatrix; + } } void ShaderUniforms::setFloat4x4(const igl::NameHandle& uniformName,