|
14 | 14 | #include "llvm/Support/MemoryBufferRef.h" |
15 | 15 | #include "llvm/Testing/Support/Error.h" |
16 | 16 | #include "gtest/gtest.h" |
| 17 | +#include <cstdint> |
17 | 18 |
|
18 | 19 | using namespace llvm; |
19 | 20 | using namespace llvm::object; |
@@ -917,5 +918,69 @@ TEST(RootSignature, ParseRootConstant) { |
917 | 918 | ASSERT_EQ(RS->getNumStaticSamplers(), 0u); |
918 | 919 | ASSERT_EQ(RS->getStaticSamplersOffset(), 44u); |
919 | 920 | ASSERT_EQ(RS->getFlags(), 17u); |
| 921 | + |
| 922 | + const auto RootParam = RS->getParameters()[0]; |
| 923 | + ASSERT_EQ((uint32_t)RootParam.ParameterType, 1u); |
| 924 | + ASSERT_EQ((uint32_t)RootParam.ShaderVisibility, 2u); |
| 925 | + ASSERT_EQ(RootParam.Constants.ShaderRegister, 15u); |
| 926 | + ASSERT_EQ(RootParam.Constants.RegisterSpace, 14u); |
| 927 | + ASSERT_EQ(RootParam.Constants.Num32BitValues, 16u); |
| 928 | + } |
| 929 | + { |
| 930 | + // ParameterType has been set to an invalid value |
| 931 | + uint8_t Buffer[] = { |
| 932 | + 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f, |
| 933 | + 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00, |
| 934 | + 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, |
| 935 | + 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 936 | + 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 937 | + 0x2c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, |
| 938 | + 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, |
| 939 | + 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 940 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 941 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 942 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 943 | + 0x00}; |
| 944 | + EXPECT_THAT_EXPECTED( |
| 945 | + DXContainer::create(getMemoryBuffer<133>(Buffer)), |
| 946 | + FailedWithMessage("unsupported parameter type value read: 255")); |
| 947 | + } |
| 948 | + { |
| 949 | + // ShaderVisibility has been set to an invalid value |
| 950 | + uint8_t Buffer[] = { |
| 951 | + 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f, |
| 952 | + 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00, |
| 953 | + 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, |
| 954 | + 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 955 | + 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 956 | + 0x2c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 957 | + 0xFF, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, |
| 958 | + 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 959 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 960 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 961 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 962 | + 0x00}; |
| 963 | + EXPECT_THAT_EXPECTED( |
| 964 | + DXContainer::create(getMemoryBuffer<133>(Buffer)), |
| 965 | + FailedWithMessage("unsupported shader visility flag value read: 255")); |
| 966 | + } |
| 967 | + { |
| 968 | + // Offset has been set to an invalid value |
| 969 | + uint8_t Buffer[] = { |
| 970 | + 0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f, |
| 971 | + 0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00, |
| 972 | + 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, |
| 973 | + 0x52, 0x54, 0x53, 0x30, 0x59, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 974 | + 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 975 | + 0x2c, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 976 | + 0x02, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, |
| 977 | + 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 978 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 979 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 980 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 981 | + 0x00}; |
| 982 | + EXPECT_THAT_EXPECTED( |
| 983 | + DXContainer::create(getMemoryBuffer<133>(Buffer)), |
| 984 | + FailedWithMessage("Reading structure out of file bounds")); |
920 | 985 | } |
921 | 986 | } |
0 commit comments