================ @@ -1157,3 +1157,49 @@ TEST(RootSignature, ParseDescriptorTable) { ASSERT_EQ(Range.OffsetInDescriptorsFromTableStart, -1); } } + +TEST(RootSignature, ParseStaticSamplers) { + { + uint8_t Buffer[] = { + 0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x52, 0x54, 0x53, 0x30, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0xa4, 0x70, 0x9d, 0x3f, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x85, 0xeb, 0x91, 0x40, 0x66, 0x66, 0x0e, 0x41, + 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00}; + DXContainer C = + llvm::cantFail(DXContainer::create(getMemoryBuffer<133>(Buffer))); + + auto MaybeRS = C.getRootSignature(); + ASSERT_TRUE(MaybeRS.has_value()); + const auto &RS = MaybeRS.value(); + ASSERT_EQ(RS.getVersion(), 2u); + ASSERT_EQ(RS.getNumParameters(), 0u); + ASSERT_EQ(RS.getRootParametersOffset(), 0u); + ASSERT_EQ(RS.getNumStaticSamplers(), 1u); + ASSERT_EQ(RS.getStaticSamplersOffset(), 24u); + ASSERT_EQ(RS.getFlags(), 17u); + + auto Sampler = *RS.samplers().begin(); + + ASSERT_EQ(Sampler.Filter, 10u); + ASSERT_EQ(Sampler.AddressU, 1u); + ASSERT_EQ(Sampler.AddressV, 2u); + ASSERT_EQ(Sampler.AddressW, 5u); + EXPECT_FLOAT_EQ(Sampler.MipLODBias, 1.23); + ASSERT_EQ(Sampler.MaxAnisotropy, 20u); + ASSERT_EQ(Sampler.ComparisonFunc, 4u); + ASSERT_EQ(Sampler.BorderColor, 0u); + EXPECT_FLOAT_EQ(Sampler.MinLOD, 4.56); ---------------- joaosaffran wrote:
`EXPECT_FLOAT_EQ` accounts for rounding errors, and make sure the floats are approximately equal instead of exactly equal, they consider an error within 4 Units in the Last Place (ULPs), here is the documentation about it https://google.github.io/googletest/reference/assertions.html#EXPECT_FLOAT_EQ https://github.com/llvm/llvm-project/pull/139963 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits