diff --git a/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp b/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp index 1a5d793cb1..a86f278ee2 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp @@ -154,20 +154,9 @@ namespace AZ bool isValidAll = true; uint32_t offset = 0; - // Rather than doing the direct validation against values directly, we have to convert the array_view - // to a raw byte array, and then check against the bytes to determine whether or not to set the - // uint32 value to 1 (true) or 0 (false). Clang when building in non-debug builds was optimizing out - // the actual 1 and 0 values, so an expression like: - // - // const uint32_t fourByteValue = values[i] ? 1 : 0; - // - // when values[0] == 205, will instead set 'fourByteValue' is assigned to '205', instead of '1'. - // In debug builds, and other microsoft compilers (debug+release), this type of optimization doesnt - // occur and we get the expected results instead - const AZ::u8* byteValues = reinterpret_cast(values.data()); for (size_t i = 0; i < values.size(); i++) { - const uint32_t fourByteValue = byteValues[i] ? 1 : 0; + const uint32_t fourByteValue = values[i] ? 1 : 0; const bool isValid = SetConstantRaw(inputIndex, &fourByteValue, offset, elementSize); isValidAll &= isValid; diff --git a/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp b/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp index 97404aafbb..0c3c82933b 100644 --- a/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp @@ -265,7 +265,7 @@ namespace UnitTest EXPECT_TRUE(m_srg->SetConstantArray(inputIndex, AZStd::array({ asBools[1], asBools[2] }))); AZStd::array_view result = m_srg->GetConstantRaw(inputIndex); AZStd::array_view resultInUint = AZStd::array_view(reinterpret_cast(result.data()), 2); - ExpectEqual({ 1 /*true*/, 0 /*false*/ }, resultInUint); + EXPECT_THAT(resultInUint, testing::ElementsAre(testing::IsTrue(), testing::IsFalse())); } }