[llvm-branch-commits] [llvm] [DirectX] Adding support for static samples is yaml2obj/obj2yaml (PR #139963)
Justin Bogner via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu May 29 12:56:08 PDT 2025
================
@@ -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);
----------------
bogner wrote:
Shouldn't these be `ASSERT_FLOAT_EQ`? IIUC `ASSERT_*` stops immediately if the condition isn't met and `EXPECT_*` allow us to diagnose multiple issues. I don't think it makes sense to use one for the floating point fields and the other for the rest of the fields.
https://github.com/llvm/llvm-project/pull/139963
More information about the llvm-branch-commits
mailing list